Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2682

Sandboxed Python: memory limits?

Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.031
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'subject:Python': 0.04; 'interpreter': 0.07; 'option,': 0.07; 'python': 0.07; 'throw': 0.09; 'somewhere': 0.11; '"your': 0.16; 'code).': 0.16; 'impose': 0.16; 'subject:memory': 0.16; 'thanks!': 0.18; '(which': 0.21; '(or': 0.22; 'code': 0.22; 'received:209.85.214.174': 0.23; 'received:mail-iw0-f174.google.com': 0.23; 'memory': 0.24; 'possible,': 0.25; 'chris': 0.27; 'google': 0.27; 'message- id:@mail.gmail.com': 0.28; 'subject:?': 0.29; 'turned': 0.31; "can't": 0.31; 'to:addr:python-list': 0.32; 'answers': 0.33; 'force': 0.35; '(my': 0.35; 'hoping': 0.36; 'received:209.85': 0.37; 'received:google.com': 0.38; 'goes': 0.38; 'but': 0.38; 'affect': 0.39; 'back.': 0.39; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'include': 0.40; 'would': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'simple': 0.60; 'straight': 0.60; 'back': 0.61; 'limit': 0.62; 'maximum': 0.62; 'today!': 0.65; 'easy,': 0.68; 'outside.': 0.84; 'subject:limits': 0.84; 'wheels': 0.84; 'presumably': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=BCHSQN9PpDTlqy8FKFbx8LIeSC2a0TXOLJ63mDLwZgw=; b=uB6G2iZ3ydGgRlkH58jbmaPsvqYtEQSw8YgDNTZwAB1f/oEjH0NRyUNE4cR5ObylO7 4pWUcfgbsiGXCb6Hw656oEavWRe2R//1gSPoBQO9AOX6VPdgJ47TcOcxDQhaBZ0WGZNA 1VsOs2Ti3aEpMIaj4KJ7wRjwYLIoU1AIVUb+w=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=uCyutZ7sJhBaRtO1KBeoggJ7qjzSijk1TFjHnO9TlWT6x6QBZqIIefS9ESd3XEryev XncHGv+4uGvvp+ZiJLf5GEBmVZI879JXmWFMIxt61yWuuQRNNFdYWNL6AGxbmXT9Dw3Q FyKgGLw9tFy5WuYtTyEhFzOP7cGGGnn1b17Z4=
MIME-Version 1.0
Date Wed, 6 Apr 2011 11:59:13 +1000
Subject Sandboxed Python: memory limits?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.62.1302055157.9059.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 82.94.164.166
X-Trace 1302055157 news.xs4all.nl 41102 [::ffff:82.94.164.166]:51778
X-Complaints-To abuse@xs4all.nl
Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2682

Show key headers only | View raw


Is it possible, and if so is it easy, to limit the amount of memory an
embedded Python interpreter is allowed to allocate? I don't want to
ulimit/rlimit the process if I don't have to (or rather, I want the
process's limit to be high, and the Python limit much lower), but just
to force Python to throw MemoryError sooner than it otherwise would
(my code can then graciously deal with the exception).

Google turned up this thread:
http://stackoverflow.com/questions/1760025/limit-python-vm-memory

The answers given include resource.setrlimit (which presumably goes
straight back to the API, which will affect the whole process), and a
simple counter (invasive to the code). But I want something that I can
impose from the outside.

I have a vague memory of reading somewhere that it's possible to
replace the Python memory allocator. This would be an option, if
there's no simple way to say "your maximum is now 16MB", but I now
can't find it back. Was I hallucinating?

Hoping not to reinvent any wheels today!

Thanks!

Chris Angelico

Back to comp.lang.python | Previous | NextNext in thread | Find similar


Thread

Sandboxed Python: memory limits? Chris Angelico <rosuav@gmail.com> - 2011-04-06 11:59 +1000
  Re: Sandboxed Python: memory limits? "Martin v. Loewis" <martin@v.loewis.de> - 2011-04-06 22:38 +0200
    Re: Sandboxed Python: memory limits? Chris Angelico <rosuav@gmail.com> - 2011-04-07 10:06 +1000
      Re: Sandboxed Python: memory limits? "Martin v. Loewis" <martin@v.loewis.de> - 2011-04-07 10:01 +0200
      Re: Sandboxed Python: memory limits? "Martin v. Loewis" <martin@v.loewis.de> - 2011-04-07 10:01 +0200
    Re: Sandboxed Python: memory limits? Chris Angelico <rosuav@gmail.com> - 2011-04-07 10:10 +1000
      Re: Sandboxed Python: memory limits? David Bolen <db3l.net@gmail.com> - 2011-04-07 14:36 -0400
        Re: Sandboxed Python: memory limits? Chris Angelico <rosuav@gmail.com> - 2011-04-08 04:59 +1000

csiph-web