Memory Context Info dump

From: Rajeev rastogi <rajeev(dot)rastogi(at)huawei(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Memory Context Info dump
Date: 2015-09-08 12:54:50
Message-ID: BF2827DCCE55594C8D7A8F7FFD3AB77159939C05@szxeml521-mbs.china.huawei.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

In our customer environment as well as during development, we have observed that many time we need to get details of memory used by each contexts in order to analyze the memory consumption/leak.
So I would like to propose one contrib function interface, which will dump the whole memory context into a file.

One of the major infrastructure i.e. the function MemoryContextStats (which dump all memory context details on the console) is already there in PG but it is being automatically called for scenarios
such as "system is out of memory".

So Now:

1. Create one contrib function dump_memctxt_info, which is when executed, it will call the existing function MemoryContextStats.

2. The file to dump will be created in the following format:

context_<process id>_<timestamp>.dump

3. The file handler will be passed to MemoryContextStats.

4. If the parameter to MemoryContextStats is NULL (All existing calls will pass NULL), then it will behave as earlier i.e. dump on console.

5. The output format of the context will be same as earlier.

6. One sample file is attached.

Use-case:
In order to check the memory leak, this contrib function can be called before and after execution of query. Then comparison of these two dump will be helpful to further analyze.

Attached is the patch. Please provide your opinion. If it is OK, I will add it to next commitFest.

Thanks and Regards,
Kumar Rajeev Rastogi

Attachment Content-Type Size
memory_ctxt_dumpv1.patch application/octet-stream 18.3 KB
context_13192_2015-09-08_181236.dump application/octet-stream 7.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2015-09-08 12:57:19 Re: proposal: function parse_ident
Previous Message Kevin Grittner 2015-09-08 12:49:44 Re: Small patch to fix an O(N^2) problem in foreign keys