Ok… I’m “freakin” out a bit here…

I’m wondering if anything is being garbage collected at all, so I wrote a small test.

class Dog(DirectObject):
    def __init__(self):
        self.Name = "Poo"
    def __del__(self):
        print("Dog Class Gone!!!\n")
    def destroy(self):
        del self.Name
Gogit = Dog()

Later I do this:


CleanMeUp does something like this:

del Inst

I noticed the del print statement never prints!!! Never!!!

This part is the worst… When calling print sys.getrefcount(Dogit), something like 6, 7 or 9 returns… How is that possible? Nothing else has ref to the Dogit instance.

Drwr, HELP!!!

I can see the line “Dog Class Gone!!!” getting printed, right after deleting the instance.

I only see it after I exit the game. Even debugging using the gc module didn’t help.

Do you have want-tk enabled in your config? I’ve noticed it does some magic to keep track of the objects… so that might be whats still holding on the reference.

I assume you remembered to clear your Gogit reference after you called CleanMeUp(Gogit)? The del operation inside the function isn’t going to do anything to the reference outside the function. You still have to remove that yourself.


A lesson learned….

I didn’t look at garbage collection too hard because of other quotes in forums stating that python will manage that, so you don’t have to worry about it too much.

I would have to disagree with that statement. However, I do realize now the proper way for deleting instances with P3D, but unfortunately, my App is too far finished for major changes now concerning garbage collection.

The good news…I was able to come up with a work around. So far, my App does not go over 160 mb RAM. It has peaked at 157 mb, once, but quickly fell lower. By the time I fully complete the game, remove creation textures and resize oversized textures….the overall RAM usage will look much different (maybe higher).

Now I will definitely take garbage collection seriously right at project start all the way to finish. Completed game with major memory leaks = no game

My work around also made resetting the game much easier; I’ve already written the game rest code and everything is ok there. Currently, I am getting the Game Save code going, which looks to be pretty simple because of the modular structure of my App (as well as the logic behind its behavior).

Game save files will be text files, but encrypted by the game itself. Since stats will be uploaded to PMME2 for site points, I can’t have players cheating by altering the save file. :smiley:

Found a big reason why Sims 3 has hiccups during play (there are others)… Compressed textures being uncompressed into video memory, where speed depends on the speed of your hard drive; not to mention some compression methods do not work well with some graphic cards.

“Is it really necessary to lower game performance, by incorporating all available game creation technology within a single game, even if such technology has no bearing on the fun factor of that game?” – mark jackson

“Stylized”, comic book visuals: (planet Zhars)

Not bad for a quick non commercial development…

Looking to close it out sometime next week (hopefully). Also looking forward to designing the best free game downloads on the internet for “PM2.” 8)

“I’ve been programming for so long…so many years…to the point I’m tired.” - mark jackson