[MMTK] problem with DeterministicUniqueIDGenerator

Guido Wagner wagner at chemie.uni-frankfurt.de
Thu Dec 18 17:08:32 UTC 2008

>> I used MMTK with the DeterministicUniqueIDGenerator (Utils.py) in a 
>> loop, which creates Universe objects from files, does some 
>> calculations and deletes these Universe Objects when done. The 
>> problem is that the id-dictionary in the 
>> DeterministicUniqueIDGenerator keeps references to every object in 
>> each universe created in the loop, so that I soon run out of memory. 
>> I have to empty the dictionary after each iteration.
>> Maybe the destructor of the Universe class should be extended to 
>> delete all objects of the universe from the id-dictionary.
> The destructor of the universe would never be called, exactly because 
> of the reference that still remains in the dictionary. Perhaps I could 
> use weak references in the dictionary, but that is something I need to 
> explore a bit more.
> Konrad.
OK, that idea just was stupid. Using a weakreferences dictionary seems 
an easy way out and since self.number would not be changed it should not 
break anything. A potetial pitfall might be if self.nuber reaches 
MAXINT, but since there are not too many objects left in the 
self.id-dictionary it schould be ok to just renumber them in that case.


More information about the mmtk mailing list