Python Memory analysis

Source: Internet
Author: User

1, change the source to recompile printing related information

The obmalloc.c file prints Maxarenas, the value is the number of arena assigned to the current environment, and the allocation of arena does not immediately allocate the corresponding pools, so for each arena,nfreepools and Ntotalpools The number of available pool and total pool to be allocated for the pool.

intArena_len =0;int_nfreepools =0 ;int_ntotalpools =0;inti; for(i =0; i<maxarenas;++i) {    if(Arenas[i].address = =0)        Continue; Arena_len++; _nfreepools+=Arenas[i].nfreepools; _ntotalpools+=Arenas[i].ntotalpools;}

Mainly this information: Maxarenas indicates the number of arena allocated, _ntotalpools indicates the number of pools allocated (memory pool capacity is _ntotalpools *4kb, each pool is 4KB).

2, Guppy

Need to be installed,
HP = Guppy.hpy ()

Hp.heap ()

You can view the current Python environment variables using memory conditions (including memory pools and non-memory pools).

There are many more ways to use it, for reference:

Http://smira.ru/wp-content/uploads/2011/08/heapy.html

3, Psutil

gets the process and system utilization (including CPU, memory, disk, network, etc.) information that the system is running.

For details, refer to:

Http://www.cnblogs.com/liu-yao/p/5678157.html

Python Memory analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.