Hi,

I still have massive memory problems running a sofia application on ARM.

I've made a couple of tests, maybe anyone has a clue what might causing 
this:

If I send 1000 invites to a simple nua client (handles are created by 
sofia), which I immediately cancel and destroy in the callback function, 
I have following effect:

1000 invites, 10 ms between each invite, memory usage goes up to 14,7% 
and stays there.
1000 invites, 100 ms between each invite, memory usage goes up to 4,3% 
and stays there.
1000 invites, 1000 ms between each invite, memory usage goes up to 2,8% 
and stays there.

Creating the handles myself:
If I just create 1000 nua_handles in one loop, and after that run a loop 
destroying the 1000 handles memory peaks at 3,9%, and then drops to 3,2 %.
If I run a loop of 1000 iterations, in each creating a handle and 
immediately call nua_handle_destroy on it, the memory usage goes up to 
2,7% and stays there.

For each test I let the program run for ~5 minutes after the last handle 
was created, to see if there is some change in memory usage, but there 
wasn't.
The memory usage of the client before any handles are created is 2,3 %, 
I've 64 MB system memory in total on my machine.
The test was done using the sofia library from darcs (last commit was 
Nov 12), I'm using arm-linux-gcc Version 3.3.2.

Maybe this is some timing issue (there is no realtime clock on the 
system), and some nua handles are not cleaned up because of this.
Any help and hints are appreciated

Thanks,
Friedrich



Friedrich Möller wrote:
> Hello list,
>
> first I want to thank the developers for the great work they are doing 
> in creating and maintaining the sofia library.
>
> But now to my problem:
> I'm writing a SIP client application to run on an ARM platform and I'm 
> having serious problems with a memory leak in the sofia library.
> It seems the memory allocated with nua_handle() is not freed if 
> nua_handle_destroy is called.
> To demonstrate the problem, I appended the source code of a mini sofia 
> program which allocates a bunch of nua_handles, and after that destroys 
> them, but the memory is never freed (on ARM). On x86 the memory is 
> freed, but sometimes not immediately; sometimes it takes a couple of 
> minutes until the memory usage of the process gets back to normal (can 
> anybody explain this?). But on ARM the memory usage doesn't go back to 
> normal, even after hours the memory is not released.
>
> I'v configured the sofia-library for arm using: ./configure --host=arm 
> --without-openssl --without-glib --prefix=/home/fsminimal/usr/local
> where /home/fsminimal is my ARM root directory. I'm linking the static 
> library.
>
> I had to undefine HAVE_CLOCK_GETTIME in the source, since 
> CLOCK_MONOTONIC is not supported on my ARM system. For comparison I even 
> undefined HAVE_CLOCK_GETTIME for the x86 platform but it didn't have any 
> negative effect there.
>
> Besides this, sofia is working as it should, but the memory consumption 
> of my application is steadily increasing (during a load test), until the 
> process is killed by the OOM .
> Does anybody have an idea what is causing this?
>
>
> Thank you in advance for your answers,
> Friedrich
>
>
>
>
> //C source start 
> ---------------------------------------------------------------
>
> #define SU_ROOT_MAGIC_T struct application_object
> #define SOA_MAGIC_T struct call_object
> #define NUA_HMAGIC_T struct call_object
>
> #include <sofia-sip/nua.h>
> #include <sofia-sip/su.h>
> #include "sofia-sip/soa.h"
> #include "sofia-sip/soa_session.h"
> #include <assert.h>
> #include <pthread.h>
> #include <string.h>
> #include <ctype.h>
> #include <stdlib.h>
>
> struct application_object{
>    su_home_t app_home[1];
>    su_root_t *app_root;
>    nua_t *nua;
> } app;
>
> struct call_object{
>    int dummy;
> };
>
> void* run_nua_event_loop()
> {
>    app.app_root = su_root_create (NULL);
>    app.nua=NULL;
>    su_init();
>    su_home_init(app.app_home);
>    assert(app.app_root);
>    su_root_run(app.app_root);
>    su_deinit();
>    su_root_destroy (app.app_root);
>    return NULL;
> }
>
> void nua_event_callback(nua_event_t event,int status, char const 
> *phrase,     nua_t *nua, nua_magic_t  *magic, nua_handle_t *nh, struct 
> call_object *co, sip_t const  *sip, tagi_t tags[])
> {
>    fprintf(stderr,"got event %i\n",event);
> }
>
> int main(){
>    int i,j;
>    pthread_t nua_thread;
>    pthread_create( &nua_thread, NULL, run_nua_event_loop,NULL);
>    sleep(2);
>    app.nua = 
> nua_create(app.app_root,nua_event_callback,&app,NUTAG_URL("sip:0.0.0.0:5060"),TAG_NULL());
>  
>
> #define ARM
> #ifdef ARM
>    int sz=10000;
> #else
>    int sz=500000;
> #endif
>    //allocating room for nua_handles
>    nua_handle_t **nh=malloc(4*sz);      assert(nh);
>
>    fprintf(stderr,"step1 alloc\n");
>    for(i=0;i<sz;i++){
>        //creating handles
>        nh[i]=nua_handle(app.nua, NULL,SIPTAG_TO_STR("[EMAIL PROTECTED]"), 
> NUTAG_AUTOANSWER(0),SIPTAG_FROM_STR("[EMAIL PROTECTED]"),TAG_END());
>    }
>    fprintf(stderr,"step1 finished\n");
>
>    fprintf(stderr,"step2 dealloc\n");
>    for(i=0;i<sz;i++){
>        //this should free
>        nua_handle_destroy(nh[i]);
>    }
>    fprintf(stderr,"step2 finished\n");
>    pthread_join( nua_thread, NULL);
> }
>
> //C source stop 
> ---------------------------------------------------------------
>
>
>
>
>   



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to