开发者

Python memory limit? Clear GC when close to limit?

How would I clear garbage collected objects before performing other memory intensive operations? Or is it done automatically when the memory is full?

Why does it seem that Python (+Eclipse) throws a Memory 开发者_JS百科Exception at 2 GB (Win32) whereas actually still some memory is unused on Windows? Are there limits defined anywhere?


You can tweak the performance of the garbage collector with the gc module -- for example, with gc.set_threshold -- or you can "manually" collect the garbage: gc.collect. However, I believe that most of the time, objects are collected as soon as their refcount goes to zero.

So to be explicit about it, (thanks delnan!) garbage collection is only an issue when there are cyclic references that keep refcounts from reaching zero.

Note also this line from the gc docs:

To debug a leaking program call gc.set_debug(gc.DEBUG_LEAK).


On Windows 32bit Application have a limit of 2GB maximum memory. There a is a boot option that will bump it to 3Gb. You can also try upgrading to 64bit Windows/Python.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜