Also, I noticed the changeset in trunk included main.py and restricted.py, 
but there were no actual changes in restricted.py. Was there supposed to be 
a change in restricted.py that was mistakenly left out?

On Saturday, January 8, 2011 12:41:27 AM UTC-5, Anthony wrote:

> As far as I can tell, the change in trunk didn't have any effect for me. 
> I'm on Windows 7 with Python 2.7.1 (just using the built-in Rocket server). 
> I added the following code to the top of default.py (outside any functions) 
> in the welcome app: 
>  
> class Foo(object):
>     def __del__(self):
>         pass
> foo = Foo()
> foo.payload = [1] * 1000000
>  
> I then load the index page of the welcome app and start watching my 
> python.exe process memory in the Windows Task Manager. Every time I reload 
> the page (by hitting F5), the memory increases by about 7MB, which is 
> exactly the same behavior I observe when running the same experiment in 
> 1.91.6 (i.e., before gc was added). These large memory increases do not 
> occur when I remove the above code from default.py. Am I doing something 
> wrong?
>  
> I'm also wondering if there may be a small memory leak either in the 
> framework or the welcome app, even without the above code. I notice that 
> when I reload the welcome app index page (without the above code), I still 
> get small memory increases, on the order of a few KB per reload. It's not 
> consistent -- sometimes a few KB, sometimes a bit more, sometimes no 
> increase at all -- but memory does consistently creep up as I keep reloading 
> (both in trunk and in 1.91.6). Is that expected behavior?
>  
> Thanks.
>  
> Anthony
>  
>  On Friday, January 7, 2011 7:56:51 PM UTC-5, Massimo Di Pierro wrote:
>
>> Mitsuhiko on reddit brings up a good issue that I was not aware of: a 
>> bug in exec. 
>>  
>> code=""" 
>> class Foo(object): 
>>     def __del__(self): 
>>         pass 
>> foo = Foo() 
>> """ 
>> while True: exec code in {} 
>>  
>> causes a memory leak. Web2py does this. The memory leak is small in 
>> practice and in fact nobody noticed it. Yet it is a concern, in 
>> theory. 
>>  
>> So far I have the current solution 
>>  
>> code=""" 
>> class Foo(object): 
>>     def __del__(self): 
>>         pass 
>> foo = Foo() 
>> """ 
>> import gc 
>> while True: 
>>     exec code in {} 
>>     gc.collect() 
>>  
>> It works for me and I cannot reproduce the leak. 
>> I patched trunk with this. Give it a try and let me know what you 
>> think. 
>>  
>> Massimo 
>>  
>>
>

Reply via email to