Issue
I am developing a PyQt desktop application, on Linux, to be used in an industrial setting. It is basically a sensor data logger which displays real time graph and saves the data into a database. As it must run continuously 5 x 24 hours per week, I need to make sure there is no memory leak for it to run smoothly.
So, what is the best way to detect memory leaks in my application?
Solution
Memory Profiling Using tracemalloc
tracemalloc
is a package included in the Python standard library.It provides detailed, block-level traces of memory allocation, including the full traceback to the line where the memory allocation occurred, and statistics for the overall memory behavior of a program.
tracemalloc
can be used to locate high-memory-usage areas of code in two ways:
- looking at cumulative statistics on memory use to identify which object allocations are using the most memory, and
- tracing execution frames to identify where those objects are allocated in the code.
A link for the documentation and PEP are below. Both provide excellent instructions on how to detect anomalies in Pythons memory management.
Answered By - alexpdev
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.