I have a (rather large) program that does CAD work written with wxPython and OpenGL. The problem I'm having is that the memory use continually grows as it is used. None of my objects seem to get deleted. Now in order to perform a hit test, I need a dictionary referencing the OpenGL IDs and the objects themselves. This dictionary needs to be cleared when something is deleted. This means as far as I know, that I have to over-ride the __del__ function for my objects. I believe this is what is causing my issues - I've read many warnings about this. Am I missing something? Should I be able to use __del__? Do I not need the separate list of IDs?

You should have a look at module weakref, which offers WeakValueDictionary and WeakKeyDictionary classes, which could suit your needs. Also consider using a memory profiler like guppy http://guppy-pe.sourceforge.net/ to examine your heap's content.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.