[Tutor] Shelve doesn't free up memory

Emile van Sebille emile at fenx.com
Tue Mar 31 19:27:47 CEST 2009


Timo wrote:
> Emile van Sebille schreef:
>> Timo wrote:
>>
>> <snip>
>>
>>> # Results file
>>> import shelve
>>>
>>> def read_result(person):
>>>    results = []
>>>
>>>    s = shelve.open(RESULTFILE)
>>>    try:
>>>        results = s[person]
>>
>>
>> Maybe passing this out prevents s from being garbage collected?
> What do you mean by passing out?

You're returning (passing out) results to the caller, which holds 
(perhaps) a reference to s...

> 
> I also tried gc.collect(), but no difference.

... which may be preventing garbage collection.

Emile



More information about the Tutor mailing list