Aug-20-2017, 02:08 AM
(Aug-19-2017, 08:06 PM)snippsat Wrote: Pyglet use Python garbage collector to release stuff from memory.I tried that in second method:
There is aPlayer.delete()
method that release resources immediately.
(Aug-19-2017, 02:54 PM)hbknjr Wrote: Here's an alternate way I tried by deleting the player object, calling gc, and recreating it but no success.
#Make a new Player object, deleting previous one @profile def makenewplayer(self): '''memory_profiler shows no change in memory usage here''' self.player.delete() #deleting current player object #del self.player gc.collect() #explicitly calling gc.collect to remove out of scope player object self.player = Player() #new player object
But the above code doesn't effect the memory usage at all. I also tried
del
which obviously doesn't work as song keeps playing in background, assigning self.player=None
and calling gc also didn't work. Tell me where I'm wrong.