Re: Interesting memory leaks ;-)



Thanks,  my specific code is too tightly coupled in a rather large 
project at the moment, so I made two patches against examples/echo in 
the most recent orbit-docs.  They are (should be) attached.

Patch pristine echo example with diff.good, run echo-server and 
echo-client, and check the memory sizes - they will remain constant.

Patch pristine echo example with diff.bad, run echo-server and 
echo-client, and check memory sizes - the echo server will grow over time.

Some simple modifications to dump memory status after the first request 
and after the 1000th request yields:

1st request:
3156 1840 pts/11   S    09:31   0:00 ./echo-server
3152 1844 pts/12   S    09:31   0:00 ./echo-client

1000th request:
3268 1952 pts/11   S    09:31   0:03 ./echo-server
3152 1844 pts/12   S    09:31   0:03 ./echo-client

As you can see, the client is fine.  The server on the other hand grew 
by approximately 116 bytes for every request.

The memory seems to be leaked when the server receives a connction 
close, which then immediately triggers a link DISCONNECT... I haven't 
looked any further, but there must be some memory associated with the 
linc handle that is not being free'ed.  No objects are listed as leaked, 
so it is not an object.

-justin

Frank Rehberger wrote:
> Justin Schoeman wrote:
> 
>> Hi all,
>>
>> My system is finally up and running, and with the long-term operation, 
>> I have noticed some memory leaks.  I have put together some simple 
>> test applications, and run through some scenarios (which are detailed 
>> below).  If anybody has some vague idea why these problems are 
>> occurring (before I start tearing orbit apart looking for it), I would 
>> appreciate it...
>>
>> [ All these scenarios describe the client side.  The server stays the 
>> same, and is implemented based on the standard skeleton servers. ]
>>
>> Scenario #1:
>> while(1) {
>>     import object1 from ior in file;
>>     call object1 method;
>>     release object1;
>> }
>>
>> The server leaks memory.
>>
>> Scenario #2:
>> import object1 from ior in file;
>> while(1) {
>>     import object2 from ior in file;
>>     call object2 method;
>>     release object2;
>> }
>> release object1;
>> No memory is leaked.
>>
>> Scenario #3:
>> As in scenario #2, but the server is restarted while the client is in 
>> the loop.
>> The server leaks memory.
>>
>> In all cases where memory leaks, the client application also stalls 
>> occasionally (for about 5 sec) before continuing.  The server still 
>> responds to other client requests during the stall.
>>
>> It seems there is some problem on the server side with a client-side 
>> last_unref of an object?
> 
> 
> yes, seems to.
> Thanks  a lot for your  effort, I know it takes much time to figure this 
> out.
> Currently I can not point to specific code line,  have you got some 
> sample code for verification?
> 
> Regards, Frank
> 
> _______________________________________________
> orbit-list mailing list
> orbit-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/orbit-list
> 
Binary files echo.orig/echo-client and echo/echo-client differ
diff -urN echo.orig/echo-client.c echo/echo-client.c
--- echo.orig/echo-client.c	Tue Apr  6 09:13:16 2004
+++ echo/echo-client.c	Tue Apr  6 09:15:38 2004
@@ -184,8 +184,12 @@
 							   filename,
 							   ev);
         etk_abort_if_exception(ev, "import service failed");
+	
+	while(1) {
+		Echo_echoString(echo_service,"hello",ev);
+		if (etk_raised_exception (ev)) return;
+	}
 
-	client_run (echo_service, ev);
         etk_abort_if_exception(ev, "service not reachable");
  
 	client_cleanup (global_orb, echo_service, ev);
Binary files echo.orig/echo-client and echo/echo-client differ
diff -urN echo.orig/echo-client.c echo/echo-client.c
--- echo.orig/echo-client.c	Tue Apr  6 09:13:16 2004
+++ echo/echo-client.c	Tue Apr  6 09:20:04 2004
@@ -74,8 +74,6 @@
                 CORBA_Environment        *ev)
 {
         /* releasing managed object */
-        CORBA_Object_release(service, ev);
-        if (etk_raised_exception(ev)) return;
  
         /* tear down the ORB */
         if (orb != CORBA_OBJECT_NIL)
@@ -180,14 +178,18 @@
 
 	g_print ("Reading service reference from file \"%s\"\n", filename);
 
-	echo_service = (Echo) etk_import_object_from_file (global_orb,
-							   filename,
-							   ev);
-        etk_abort_if_exception(ev, "import service failed");
+	while(1) {
+		echo_service = (Echo) etk_import_object_from_file (global_orb,
+								   filename,
+								   ev);
+	        etk_abort_if_exception(ev, "import service failed");
+	
+		Echo_echoString(echo_service,"hello",ev);
+		if (etk_raised_exception (ev)) return;
+	        CORBA_Object_release(echo_service, ev);
+        	if (etk_raised_exception(ev)) return;
+	}
 
-	client_run (echo_service, ev);
-        etk_abort_if_exception(ev, "service not reachable");
- 
 	client_cleanup (global_orb, echo_service, ev);
         etk_abort_if_exception(ev, "cleanup failed");
  


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]