Interpreting objgraph numbers: memory leak?
I have a Python client-server application and its server has been running for about 4 days... Its memory usage (as reported by /proc/PID/status -> VmSize) has grown to about 660Mb, and I was wondering if there could be a memory leak, so I used objgraph to print out its memory usage (first 20 object types):
58524 tuple
33270 dict
15483 function
9976 list
5396 set
2644 weakref
2489 builtin_function_or_method
2482 instancemethod
1898 OrderedSet
1751 _BindParamClause
1680 _generated_label
1485 Comparator
1398 type
1315 InstrumentedAttribute
1267 Custo开发者_C百科mColumn
1165 cell
1146 ScalarAttributeImpl
1146 ColumnProperty
1146 ColumnLoader
1075 wrapper_descriptor
I don't see anything particularly "smelly" there, am I missing something? Maybe this is just because Python doesn't release unused memory to the OS immediately?
(This is a CherryPy+SQLAlchemy application)To acquire more meaningful data, keep the server running for several days, and pull this summary once per day. The key will be to see which kinds of objects are accumulating from one day to the next; those object types will be the most likely candidates for your memory leak! Let us know what you find.
精彩评论