[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Frantic (again)




On Jun 26, 2006, at 1:00 PM, Brian Fisher wrote:

On 6/26/06, David Mikesell <dave_mikesell@xxxxxxxxxxx> wrote:
> Perhaps you should also take a look a the garbage collector for reducing
> the memory usage. This version is better as the last one but still, 500
> MB is to high mem usage. I wonder what is taking so much memory.


How does pygame.mixer.music manage memory? When I load a new track is
the previous one unloaded?


A good way to test stuff like this (memory allocation and speed stuff
where the operations of an underlying lib are not tractable) is to
disable certain features and see how things change.

So if you run a specific test with music on, then run it again with
music off, what are the differences?

... also one thing to note when trying to track down mem usage of a
game, I remember that python never freed stuff in favor of keeping
allocated memory in a pool (at least that is true with 2.3) so that
the (virtual) memory allocation from the OS' perspective would always
be the largest that it ever was at any given moment - so if an app's
mem usage ballooned to 1GB, then from then on only used like 128MB, it
would say 1GB forever. So if you see a high mem usage which is not
growing, it may have been a function that allocated a bunch to do some
temporary one-time thing...

That's not really true and it never has been. Python does keep some pools of memory around forever to allocate small objects (the pymalloc allocator), but Python definitely frees memory. Operating systems may or may not actually report that memory as freed when Python calls free() though.



-bob