2010/2/20 Alec Matusis <matu...@yahoo.com>:
> Thank you Werner!
>
> I am playing with your object counter. But before I can interpret the
> results, I have to ask a possibly stupid question.
> Can someone explain to me this behavior of python 2.6 on x86 linux 2.6.24:
>
> 1) start interpreter
> Check the size of the interpreter process:
> $ps -orss -p24316
>  RSS
>  4212
>
> Size is 4MB, fine.
>
> 2) Allocate a huge chunk of memory:
>>>> x=range(1,10000000)
> Check the size of the interpreter process:
> $ps -orss -p24316
>  RSS
>  322460
>
> The RSS memory grew by 322460KB =314MB, as I expected
>
> 3) Delete this object:
>>>> del x
> Check the size of the interpreter process:
> $ps -orss -p24316
>  RSS
>  244332
>
> So, the memory is far off its original value! It's up by nearly 240MB, and
> it never gets released. Why is that?
>
> 4)
>>>> import gc
>>>> gc.collect()
> 0
> $ps -orss -p24316
>  RSS
> 244404
> Not much luck here!
>
>

Repeat steps 2 to 4. No more memory is used. Python don't leaks more memory.

Repeat the steps reserving memory like this:
x = [0] * 10000000

The memory is cleaned. The problem is in the virtual machine use of integers.

Excuse my poor explanation. My english is very bad,

Reggards,

Javi

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to