Pythonista-Issues icon indicating copy to clipboard operation
Pythonista-Issues copied to clipboard

Memory usage viewing?

Open TobiLikesGuys opened this issue 8 months ago • 3 comments

Hi!

I have a script with a ton of sprites, moving objects, calculations, and more using the scene module. I have been wanting to record, or at least view the memory usage of the entire program as a whole, or isolate it down to just a function or section.

I dug around, and the modules I found installed aren’t really what I was looking for. I wanted to know if there was a built in method of viewing the applications memory usage, or any method of calculating the performance implications of my program.

I am aware of pstats and cProfile modules, but as far as I could get they only return function call and return times. Is there a built in method for getting the memory usage of pythonista?

P.S I wanted to refer more to the memory used while rendering graphics.

TobiLikesGuys avatar May 13 '25 13:05 TobiLikesGuys

Second answer to https://stackoverflow.com/questions/938733

>>> import resource
>>> resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024

cclauss avatar May 13 '25 14:05 cclauss

Second answer to https://stackoverflow.com/questions/938733

>>> import resource
>>> resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024

This does seem to return a value, but the value never changes even as the program uses more memory. Is this a value representing the maximum amount of memory the app is allowed to use maybe?

TobiLikesGuys avatar May 13 '25 14:05 TobiLikesGuys

https://docs.python.org/3/library/resource.html

https://docs.python.org/3/library/resource.html#resource-usage

cclauss avatar May 13 '25 14:05 cclauss