www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Get memory usage report from GC

reply tcak <1ltkrs+3wyh1ow7kzn1k sharklasers.com> writes:
Is there any way (I checked core.memory already) to collect 
report about memory usage from garbage collector? So, I can see a 
list of pointer and length information. Since getting this 
information would require another memory area in heap, it could 
be like logging when report is asked.

My long running but idle program starts using 41.7% of memory 
(that's close to 3GB), and it is not obvious whether the memory 
is allocated by a single variable, or many variables.
Feb 19 2016
parent reply tcak <1ltkrs+3wyh1ow7kzn1k sharklasers.com> writes:
On Saturday, 20 February 2016 at 05:33:00 UTC, tcak wrote:
 Is there any way (I checked core.memory already) to collect 
 report about memory usage from garbage collector? So, I can see 
 a list of pointer and length information. Since getting this 
 information would require another memory area in heap, it could 
 be like logging when report is asked.

 My long running but idle program starts using 41.7% of memory 
 (that's close to 3GB), and it is not obvious whether the memory 
 is allocated by a single variable, or many variables.
My mistake, it is close to 512MB.
Feb 19 2016
parent reply Jon D <jond noreply.com> writes:
On Saturday, 20 February 2016 at 05:34:01 UTC, tcak wrote:
 On Saturday, 20 February 2016 at 05:33:00 UTC, tcak wrote:
 Is there any way (I checked core.memory already) to collect 
 report about memory usage from garbage collector? So, I can 
 see a list of pointer and length information. Since getting 
 this information would require another memory area in heap, it 
 could be like logging when report is asked.

 My long running but idle program starts using 41.7% of memory 
 (that's close to 3GB), and it is not obvious whether the 
 memory is allocated by a single variable, or many variables.
My mistake, it is close to 512MB.
Doesn't sounds like precisely what you want, but there are summary reports of GC activity available via the "--DRT-gcopt=profile:1" command line option. More info at: http://dlang.org/spec/garbage.html --Jon
Feb 19 2016
parent reply tcak <1ltkrs+3wyh1ow7kzn1k sharklasers.com> writes:
On Saturday, 20 February 2016 at 05:55:26 UTC, Jon D wrote:
 On Saturday, 20 February 2016 at 05:34:01 UTC, tcak wrote:
 On Saturday, 20 February 2016 at 05:33:00 UTC, tcak wrote:
 Is there any way (I checked core.memory already) to collect 
 report about memory usage from garbage collector? So, I can 
 see a list of pointer and length information. Since getting 
 this information would require another memory area in heap, 
 it could be like logging when report is asked.

 My long running but idle program starts using 41.7% of memory 
 (that's close to 3GB), and it is not obvious whether the 
 memory is allocated by a single variable, or many variables.
My mistake, it is close to 512MB.
Doesn't sounds like precisely what you want, but there are summary reports of GC activity available via the "--DRT-gcopt=profile:1" command line option. More info at: http://dlang.org/spec/garbage.html --Jon
I checked it out now. Yes, it is not that much useful unfortunately. The process is a daemon. stdin, stdout, and stderr are forwarded to /dev/null, thus, there is nothing like getting a text report at the end of process. I am still looking for a way to at least hook up to GC, so when it allocates, or deallocates, I could log it myself.
Feb 19 2016
parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 20.02.2016 07:22, tcak wrote:
 On Saturday, 20 February 2016 at 05:55:26 UTC, Jon D wrote:
 On Saturday, 20 February 2016 at 05:34:01 UTC, tcak wrote:
 On Saturday, 20 February 2016 at 05:33:00 UTC, tcak wrote:
 Is there any way (I checked core.memory already) to collect report
 about memory usage from garbage collector? So, I can see a list of
 pointer and length information. Since getting this information would
 require another memory area in heap, it could be like logging when
 report is asked.

 My long running but idle program starts using 41.7% of memory
 (that's close to 3GB), and it is not obvious whether the memory is
 allocated by a single variable, or many variables.
My mistake, it is close to 512MB.
Doesn't sounds like precisely what you want, but there are summary reports of GC activity available via the "--DRT-gcopt=profile:1" command line option. More info at: http://dlang.org/spec/garbage.html --Jon
I checked it out now. Yes, it is not that much useful unfortunately. The process is a daemon. stdin, stdout, and stderr are forwarded to /dev/null, thus, there is nothing like getting a text report at the end of process. I am still looking for a way to at least hook up to GC, so when it allocates, or deallocates, I could log it myself.
You can add path-to-druntime/src/gc/gc.d to your build command line and add option -debug=PRINTF_TO_FILE. This will redirect output to gcx.log. If you add option -debug=PRINTF, it will print some API calls. You might have to check gc.d whether the ones that interest you are commented out, though.
Feb 21 2016