[ python-Bugs-1524938 ] MemoryError with a lot of available memory - gc not called

SourceForge.net noreply at sourceforge.net
Sun Jul 23 22:19:09 CEST 2006


Bugs item #1524938, was opened at 2006-07-19 05:46
Message generated for change (Comment added) made by markmat
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1524938&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Mark Matusevich (markmat)
Assigned to: Nobody/Anonymous (nobody)
Summary: MemoryError with a lot of available memory - gc not called

Initial Comment:
Also the gc behavior is consistent with the
documentation, I beleave it is wrong. I think, that Gc
should be called automatically before any memory
allocation is raised.

Example 1:
for i in range(700): 
   a = [range(5000000)]
   a.append(a)
   print i

This example will crash on any any PC with less then
20Gb RAM. On my PC (Windows 2000, 256Mb) it crashes at
i==7.
Also, this example can be fixed by addition of a call
to gc.collect() in the loop, in real cases it may be
unreasonable. 


----------------------------------------------------------------------

>Comment By: Mark Matusevich (markmat)
Date: 2006-07-23 23:19

Message:
Logged In: YES 
user_id=1337765

Sorry, my last comment was to illume (I am slow typer :( )

----------------------------------------------------------------------

Comment By: Mark Matusevich (markmat)
Date: 2006-07-23 23:11

Message:
Logged In: YES 
user_id=1337765

This is exectly what I meant. 
For my recollection, this is the policy in Java GC. I never
had to handle MemoryError in Java, because I knew, that I
really do not have any more memory.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2006-07-23 23:00

Message:
Logged In: YES 
user_id=21627

This is very difficult to implement. The best way might be
to introduce yet another allocation function, one that
invokes gc before failing, and call that function in all
interesting places (of which there are many).

Contributions are welcome and should probably start with a
PEP first.

----------------------------------------------------------------------

Comment By: Rene Dudfield (illume)
Date: 2006-07-20 02:20

Message:
Logged In: YES 
user_id=2042

Perhaps better than checking before every memory allocation,
would be to check once a memory error happens in an allocation.

That way there is only the gc hit once there is low memory.

So...

res = malloc(...);
if(!res) {
    gc.collect();
}

res = malloc(...);
if(!res) {
    raise memory error.
}





----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1524938&group_id=5470


More information about the Python-bugs-list mailing list