Re: Memory Issue
- From: Allin Cottrell <cottrell wfu edu>
- To: Preeti Joshi <preetijoshi79 gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Memory Issue
- Date: Mon, 18 Dec 2006 10:56:29 -0500 (EST)
On Mon, 18 Dec 2006, Preeti Joshi wrote:
The above code creates a main window and from button1 click creates a
message box . On closing this message box , memory allocated to message box
should have been freed. However gnome-system-monitor shows the following
stats:
when main window is displayed: 3.5 MB
when message box is also displayed: 3.9 MB
message box closed: 3.9 MB
main window closed through 'X' button: 3.9 MB
You don't have any call to gtk_main_quit() in your program, so
closing the main window will not free the basic gtk/gnome memory
allocation.
Besides that, gnome-system-monitor is not a leak checker. If you
saw the memory usage increasing every time you opened and closed
the message box, that would indeed suggest a leak. But what
you're describing above is normal behaviour. When a program calls
free(), that action in principle makes the previously claimed
dynamic memory available to the operating system. But the
operating system need not reclaim it. The OS may leave the memory
in question "lying around" for possible future use by the same
program. This increases efficiency. For example, when you open
the dialog a second time, the OS doesn't have to "find" the extra
memory needed, it's still allocated to your program.
People sometimes seem to think that good memory management means
having as much free RAM as possible available at any given
moment. But if you think about it, that makes no sense. Memory
is there to be used. It's more efficient (if you're not about to
run out of RAM) to keep previous memory allocations cached.
Allin Cottrell
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]