Calculating memory fragmentation in Python
问题 I have a long running process that allocates and releases objects constantly. Although objects are being freed, the RSS mem usage goes up over time. How can I calculate how much fragmentation is happening? One possibility is to calculate RSS / sum_of_allocations and take that as an indicator. even then, how to do I calculate the denominator (sum_of_allocations). 回答1: Check out the Garbage Collector interface, gc. http://docs.python.org/2/library/gc.html You can inspect the objects are being