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

SourceForge.net noreply at sourceforge.net
Thu Jul 20 01:20:07 CEST 2006


Bugs item #1524938, was opened at 2006-07-19 02:46
Message generated for change (Comment added) made by illume
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: Rene Dudfield (illume)
Date: 2006-07-19 23: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