Python Forum
Trusting the garbage collector
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trusting the garbage collector
#1
Just ran into a case where the garbage collector is absolutely not doing what I need it to do.

Context: I'm creating a game hub from which users can enter a number of different mini games. The mini games may have their own resources which load when they are started up, but they need to release this memory when you exit back to the menu. My initial intuition was to kill all links to these resources so when the specific game instance goes out of scope the gc should reclaim the memory. This has unfortunately proved problematic. The resources do not get cleaned up quickly, and in fact if I exit and restart the mini game from the hub I can push the memory usage as high as I want... which is not good.

I have now added an explicit gc.collect call after a state flip and this gets the job done, but I do wonder why the automatic gc is being so unreliable. I would rather not have to resort to this.
Reply


Messages In This Thread
Trusting the garbage collector - by Mekire - Mar-29-2018, 02:01 AM
RE: Trusting the garbage collector - by Larz60+ - Mar-29-2018, 02:13 AM
RE: Trusting the garbage collector - by Mekire - Mar-29-2018, 02:45 AM
RE: Trusting the garbage collector - by Larz60+ - Mar-29-2018, 04:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  collector of a bunch of named stuff Skaperen 1 2,060 Sep-29-2018, 03:20 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020