public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Memory Dump
@ 2012-04-29 14:40 Hei Chan
  2012-05-03  6:56 ` xgsa
  2012-05-09 20:25 ` Tom Tromey
  0 siblings, 2 replies; 8+ messages in thread
From: Hei Chan @ 2012-04-29 14:40 UTC (permalink / raw)
  To: gdb



Hi,

I wonder whether it is possible to dump all the objects created in the memory at the moment with GDB (I am on v7.0.1).

What I am trying to achieve is to identify which types of objects take up most of the memory at the moment.

Valgrind doesn't catch it and so I believe that it is some logical bug in my code that keeps creating the objects and free all of them at the end (i.e. program terminated).

Thanks in advance.


Cheers,
Hei

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Memory Dump
  2012-04-29 14:40 Memory Dump Hei Chan
@ 2012-05-03  6:56 ` xgsa
  2012-05-03 14:17   ` Aurelian Melinte
                     ` (2 more replies)
  2012-05-09 20:25 ` Tom Tromey
  1 sibling, 3 replies; 8+ messages in thread
From: xgsa @ 2012-05-03  6:56 UTC (permalink / raw)
  To: Hei Chan; +Cc: gdb

Hi,

I am not sure, but it seems massif (the tool from the valgrind 
toolchain) could help you.

P.S. However the question is still interesting - is there a possibility 
to solve the problem with gdb? Could someone answer it?

Anton.

-------- Original message --------
>
> Hi,
>
> I wonder whether it is possible to dump all the objects created in the memory at the moment with GDB (I am on v7.0.1).
>
> What I am trying to achieve is to identify which types of objects take up most of the memory at the moment.
>
> Valgrind doesn't catch it and so I believe that it is some logical bug in my code that keeps creating the objects and free all of them at the end (i.e. program terminated).
>
> Thanks in advance.
>
>
> Cheers,
> Hei
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Memory Dump
  2012-05-03  6:56 ` xgsa
@ 2012-05-03 14:17   ` Aurelian Melinte
  2012-05-03 19:23   ` Philippe Waroquiers
  2012-05-06  0:43   ` Hei Chan
  2 siblings, 0 replies; 8+ messages in thread
From: Aurelian Melinte @ 2012-05-03 14:17 UTC (permalink / raw)
  To: xgsa, structurechart; +Cc: gdb


> Hi,
> 
> I am not sure, but it seems massif (the tool from the valgrind 
> toolchain) could help you.
> 
> P.S. However the question is still interesting - is there a possibility 
> to solve the problem with gdb? Could someone answer it?


The only way I know is to write an interposition library to hook malloc()/memalign()/realloc()/free()/mmap()/munmap()/sbrk() and maybe more.

An easier alternative might be mcheck() - depending what exactly you are looking for.

Otherwise, wrap malloc() and friends within your own functions (xmalloc()) and use only these inside your program, etc.

Regards,
a.


> 
> Anton.
> 
> -------- Original message --------
> >
> > Hi,
> >
> > I wonder whether it is possible to dump all the objects created in the
> memory at the moment with GDB (I am on v7.0.1).
> >
> > What I am trying to achieve is to identify which types of objects take
> up most of the memory at the moment.
> >
> > Valgrind doesn't catch it and so I believe that it is some logical bug
> in my code that keeps creating the objects and free all of them at the end
> (i.e. program terminated).
> >
> > Thanks in advance.
> >
> >
> > Cheers,
> > Hei
> >
> >
> 
> 

-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                                  
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Memory Dump
  2012-05-03  6:56 ` xgsa
  2012-05-03 14:17   ` Aurelian Melinte
@ 2012-05-03 19:23   ` Philippe Waroquiers
  2012-05-06  0:55     ` Hei Chan
  2012-05-06  0:43   ` Hei Chan
  2 siblings, 1 reply; 8+ messages in thread
From: Philippe Waroquiers @ 2012-05-03 19:23 UTC (permalink / raw)
  To: xgsa, Hei Chan; +Cc: gdb

> Hi,
> 
> I am not sure, but it seems massif (the tool from the valgrind 
> toolchain) could help you.
> 
> P.S. However the question is still interesting - is there a possibility 
> to solve the problem with gdb? Could someone answer it?

Valgrind massif or Valgrind memcheck are providing functionalities
to give heap information. Note that Valgrind 3.7.0 has
an integrated gdbserver, which means you can do "heap snaphots"
or "leak search" or similar on request from a gdb (or from command line).

Philippe

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Memory Dump
  2012-05-03  6:56 ` xgsa
  2012-05-03 14:17   ` Aurelian Melinte
  2012-05-03 19:23   ` Philippe Waroquiers
@ 2012-05-06  0:43   ` Hei Chan
  2 siblings, 0 replies; 8+ messages in thread
From: Hei Chan @ 2012-05-06  0:43 UTC (permalink / raw)
  To: xgsa; +Cc: gdb

Never used massif before.  Just tried it for few hours, and it doesn't seem like to be able to take snapshot when a user requests for/signals to.

I had to instrument my code to malloc big chunk of memory in a predefined time (i.e. sleep(x)) and deallocate later to trigger a snapshot to "stamp" the "times".

A quite useful tool tho, but I am not on 3.7.0 yet that offers pages-as-heap=yes option; and it shows nothing too fishy to me yet :(

Very appreciate your input tho.


Cheers,
Hei


________________________________
From: xgsa <xgsa@yandex.ru>
To: Hei Chan <structurechart@yahoo.com> 
Cc: "gdb@sourceware.org" <gdb@sourceware.org> 
Sent: Wednesday, May 2, 2012 11:55 PM
Subject: Re: Memory Dump

Hi,

I am not sure, but it seems massif (the tool from the valgrind 
toolchain) could help you.

P.S. However the question is still interesting - is there a possibility 
to solve the problem with gdb? Could someone answer it?

Anton.

-------- Original message --------
>
> Hi,
>
> I wonder whether it is possible to dump all the objects created in the memory at the moment with GDB (I am on v7.0.1).
>
> What I am trying to achieve is to identify which types of objects take up most of the memory at the moment.
>
> Valgrind doesn't catch it and so I believe that it is some logical bug in my code that keeps creating the objects and free all of them at the end (i.e. program terminated).
>
> Thanks in advance.
>
>
> Cheers,
> Hei
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Memory Dump
  2012-05-03 19:23   ` Philippe Waroquiers
@ 2012-05-06  0:55     ` Hei Chan
  2012-05-06  7:49       ` Philippe Waroquiers
  0 siblings, 1 reply; 8+ messages in thread
From: Hei Chan @ 2012-05-06  0:55 UTC (permalink / raw)
  To: Philippe Waroquiers, xgsa; +Cc: gdb

Hi Phillippe,

The feature you mentioned sounds interesting.

Is it capable of taking heap snapshot per user request/command?

What's the name of that feature?  I want to look it up.   Or do you have a link?  (don't see it in the release note of Valgrind 3.7.0).

Thanks in advance.


Cheers,
Hei


----- Original Message -----
From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
To: xgsa <xgsa@yandex.ru>; Hei Chan <structurechart@yahoo.com>
Cc: gdb@sourceware.org
Sent: Thursday, May 3, 2012 12:22 PM
Subject: Re: Memory Dump

> Hi,
> 
> I am not sure, but it seems massif (the tool from the valgrind toolchain) could help you.
> 
> P.S. However the question is still interesting - is there a possibility to solve the problem with gdb? Could someone answer it?

Valgrind massif or Valgrind memcheck are providing functionalities
to give heap information. Note that Valgrind 3.7.0 has
an integrated gdbserver, which means you can do "heap snaphots"
or "leak search" or similar on request from a gdb (or from command line).

Philippe

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Memory Dump
  2012-05-06  0:55     ` Hei Chan
@ 2012-05-06  7:49       ` Philippe Waroquiers
  0 siblings, 0 replies; 8+ messages in thread
From: Philippe Waroquiers @ 2012-05-06  7:49 UTC (permalink / raw)
  To: Hei Chan; +Cc: xgsa, gdb

On Sat, 2012-05-05 at 17:55 -0700, Hei Chan wrote:
> Hi Phillippe,
> 
> The feature you mentioned sounds interesting.
> 
> Is it capable of taking heap snapshot per user request/command?
Yes. You can request a snapshot on user request,
either from the command line, or from a gdb connected to the Valgrind
gdbserver.

For gdbserver explanations, see
http://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver
For massif snapshot requests, see
http://www.valgrind.org/docs/manual/ms-manual.html#ms-manual.monitor-commands

So, from a shell command line, to request a massif snapshot, you do
e.g.:
    vgdb snapshot filename_for_your_snapshot

From gdb connected to Valgrind gdbserver, you put breaks where relevant,
and then such a break is reached:
    monitor snapshot filename_for_your_snapshot

Note also that memcheck also provides on demand leak search
(including for still reachable blocks), showing the delta
with the previous leak search.

In 3.8.0 SVN (not yet released), Valgrind gdbserver+memcheck also
provides functionalities to list the still allocated blocks, and search
for "who" still points at these allocated blocks.

Philippe


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Memory Dump
  2012-04-29 14:40 Memory Dump Hei Chan
  2012-05-03  6:56 ` xgsa
@ 2012-05-09 20:25 ` Tom Tromey
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2012-05-09 20:25 UTC (permalink / raw)
  To: Hei Chan; +Cc: gdb

>>>>> "Hei" == Hei Chan <structurechart@yahoo.com> writes:

Hei> I wonder whether it is possible to dump all the objects created in the
Hei> memory at the moment with GDB (I am on v7.0.1).

Hei> What I am trying to achieve is to identify which types of objects take
Hei> up most of the memory at the moment.

In addition to the other answers, you might be interested in gdb-heap:

    https://fedorahosted.org/gdb-heap/

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-05-09 20:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-29 14:40 Memory Dump Hei Chan
2012-05-03  6:56 ` xgsa
2012-05-03 14:17   ` Aurelian Melinte
2012-05-03 19:23   ` Philippe Waroquiers
2012-05-06  0:55     ` Hei Chan
2012-05-06  7:49       ` Philippe Waroquiers
2012-05-06  0:43   ` Hei Chan
2012-05-09 20:25 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).