RE: Memory management in gtk
- From: "Vishak V. Kurup" <vishak kurup nestgroup net>
- To: <jcupitt gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: RE: Memory management in gtk
- Date: Tue, 19 Oct 2010 14:48:15 +0530
Thank you jhon..i have checked using Valgrind and it is not showing any memory leaks. So I was checking the
memory usage using "top". I will check using ur suggestion. Thank you verymuch.
-----Original Message-----
From: jcupitt gmail com [mailto:jcupitt gmail com]
Sent: Tuesday, October 19, 2010 2:43 PM
To: Vishak V. Kurup
Cc: gtk-app-devel-list gnome org
Subject: Re: Memory management in gtk
On 19 October 2010 06:22, Vishak V. Kurup <vishak kurup nestgroup net> wrote:
I am having a small problem related to GTK. My application is having
around 15 windows. When I start my application and check the memory
usage using "top" utility it shows around 19MB. When a new window is
created it may increase upto 22 MB (varies each time). And after I
destroy the new window my memory is not getting reduced. Could anyone
please tell me why memory usage is not decreased even after I destroy
widget.
top is not the best way to see memory use of a program, or to check for leaks.
When a program starts, the system hands over a large chunk of ram to
the memory library. This library then hands out the memory to the
program in small bits as the program asks for it. If the chunk is
exhausted, the library asks for more memory from the OS. When memory
is freed, the memory library does not return it to the host operating
system (with certain strange exceptions), instead it keeps it around
for reuse. As a result, you will (almost) never see the memuse fall,
as reported by top, for any program.
To check for leaks, you need to use a special tool. In my opinion, the
most useful under Linux is valgrind. Run it with something like:
export G_DEBUG=gc-friendly
This makes Glib clear certain memory areas after using them, too.
export G_SLICE=always-malloc
This completely disables the magazine and slab allocator in Glib,
and makes it use plain malloc()/free() instead.
valgrind --leak-check=yes \
myprog ... > myprog-vg.log 2>&1
You will get some false positives. I have a suppressions file here:
http://www.vips.ecs.soton.ac.uk/development/nip2.supp
Which hides all the false positives from the gtk stack.
John
***** Confidentiality Statement/Disclaimer *****
This message and any attachments is intended for the sole use of the intended recipient. It may contain
confidential information. Any unauthorized use, dissemination or modification is strictly prohibited. If you
are not the intended recipient, please notify the sender immediately then delete it from all your systems,
and do not copy, use or print. Internet communications are not secure and it is the responsibility of the
recipient to make sure that it is virus/malicious code exempt.
The company/sender cannot be responsible for any unauthorized alterations or modifications made to the
contents. If you require any form of confirmation of the contents, please contact the company/sender. The
company/sender is not liable for any errors or omissions in the content of this message.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]