GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Memory leak with glib2... help needed

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
amit_sahrawat



Joined: 23 Apr 2008
Posts: 2

PostPosted: Wed Apr 23, 2008 5:12 am    Post subject: Memory leak with glib2... help needed Reply with quote

hi,
I am writing a simple application to grab window_opened event, I wish to get an event every time a window gets opened on the system.
So I did,
WnckScreen *screen = wnck_screen_get(0);

g_signal_connect(screen, "window_opened", (GCallback)WindowOpenCallback, NULL);
from my thread in addition to init part.
Now, I am getting the desired results but problem is over a period of time the top shows memory increase for my program(increase in RES memory in chunks of 4k,8k,12k...)...
I tried looking for the things.
Please help me out if this is a known issue with any of the library.
Thanks in advance...
Regards,
Amit Sahrawat
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 376
Location: State College, Pennsylvania

PostPosted: Wed Apr 23, 2008 1:27 pm    Post subject: Reply with quote

What type of memory are you looking at? If you look at the wrong type of memory reading, it could appear as though your program is leaking when it is not. Could you post some code? But first, read this article on memory readings in Linux: http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html
Back to top
amit_sahrawat



Joined: 23 Apr 2008
Posts: 2

PostPosted: Thu Apr 24, 2008 4:35 am    Post subject: Reply with quote

Nice Article with good explanation, Thanks

My code is like this,

void InitScreens()
{
WnckScreen *screen = wnck_screen_get(0);

//Connect a callback to the window opened event in libwnck
g_signal_connect(screen, "window_opened", (GCallback)WindowOpenCallback, NULL);

}

capture_main()
{
int argc = 1;
char **argv = (char**)malloc(sizeof(char*));

/* Initializing the mutex for window control*/
pthread_mutex_init(&window_mutex,NULL); /*This is relevant to my data structures */

pthread_mutex_init(&rsrpmutex,NULL);/*This is relevant to my data structures */

//Initialise GDK
gdk_init(&argc, &argv);

//Connect to every screen
InitScreens();

loop = g_main_loop_new(NULL, TRUE);
g_main_loop_run(loop);

free(argv);
argv=NULL;
}
Then I have the callback function,
where I get the windows name and prepare a list for the same.

After running this program and opening up windows very frequently, say around 4-5 windows every minute...
the TOP programs shows increase in RES memory for the program.


26248 root 18 0 124m 4712 3780 S 0.3 1.4 0:00.78 capture
26248 root 18 0 124m 4712 3780 S 0.3 1.4 0:00.79 capture
26248 root 18 0 124m 4712 3780 S 0.3 1.4 0:00.80 capture
26248 root 18 0 124m 4712 3780 S 0.3 1.4 0:00.81 capture
26248 root 18 0 124m 4720 3788 S 0.3 1.4 0:00.82 capture
26248 root 18 0 124m 4720 3788 S 9.6 1.4 0:01.11 capture
26248 root 18 0 124m 4720 3788 S 0.3 1.4 0:01.12 capture
26248 root 18 0 124m 4720 3788 S 0.7 1.4 0:01.14 capture
26248 root 18 0 124m 4720 3788 S 9.0 1.4 0:01.41 capture
26248 root 18 0 124m 4720 3788 S 1.3 1.4 0:01.45 capture
26248 root 18 0 124m 4720 3788 S 1.0 1.4 0:01.48 capture
26248 root 18 0 124m 4720 3788 S 11.7 1.4 0:01.83 capture
26248 root 18 0 124m 4720 3788 S 0.7 1.4 0:01.85 capture
26248 root 18 0 124m 4720 3788 S 0.7 1.4 0:01.87 capture
26248 root 18 0 124m 4724 3788 S 10.6 1.4 0:02.19 capture
26248 root 18 0 124m 4728 3788 S 9.6 1.4 0:02.48 capture
26248 root 18 0 124m 4728 3788 S 1.0 1.4 0:02.51 capture
26248 root 18 0 124m 4728 3788 S 0.3 1.4 0:02.52 capture
26248 root 18 0 124m 4728 3788 S 0.3 1.4 0:02.53 capture
26248 root 18 0 124m 4736 3788 S 9.3 1.4 0:02.81 capture
26248 root 18 0 124m 4736 3788 S 1.3 1.4 0:02.85 capture
26248 root 18 0 124m 4736 3788 S 0.3 1.4 0:02.86 capture
26248 root 18 0 124m 4736 3788 S 0.7 1.4 0:02.88 capture
26248 root 18 0 124m 4740 3788 S 5.3 1.4 0:03.04 capture
26248 root 18 0 124m 4740 3788 S 5.0 1.4 0:03.19 capture
26248 root 18 0 124m 4740 3788 S 0.3 1.4 0:03.20 capture
26248 root 18 0 124m 4740 3788 S 0.7 1.4 0:03.22 capture
26248 root 18 0 124m 4748 3788 S 4.3 1.4 0:03.35 capture
26248 root 18 0 124m 4748 3788 S 5.0 1.4 0:03.50 capture
26248 root 18 0 124m 4748 3788 S 0.3 1.4 0:03.51 capture
26248 root 18 0 124m 4748 3788 S 0.3 1.4 0:03.52 capture
26248 root 18 0 124m 4748 3788 S 0.3 1.4 0:03.53 capture
26248 root 18 0 124m 4748 3788 S 1.0 1.4 0:03.56 capture
26248 root 18 0 124m 4752 3788 S 6.7 1.4 0:03.76 capture
26248 root 18 0 124m 4752 3788 S 4.7 1.4 0:03.90 capture
26248 root 18 0 124m 4832 3868 S 1.0 1.4 0:03.93 capture

Regards,
Amit Sahrawat
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP