[OpenSIPS-Devel] Out of pkg mem with own module
Schumann Sebastian
Sebastian.Schumann at t-com.sk
Tue Nov 11 09:40:25 CET 2008
Hi Bogdan
I am not sure, but I figured the problem must come from my module. And I have only two times where I use pkg_malloc and both look like the snip.
I will try to debug it, let's see if I will be successful. Thanks for this direction.
Sebastian
> -----Original Message-----
> From: Bogdan-Andrei Iancu [mailto:bogdan at voice-system.ro]
> Sent: Monday, 10. November 2008 17:52
> To: Schumann Sebastian
> Cc: devel at lists.opensips.org
> Subject: Re: [OpenSIPS-Devel] Out of pkg mem with own module
>
> Hi Sebastian,
>
> The snip looks ok - are you sure the leak comes from here?
> have you tried to use the memory debuger to identify the
> source - http://www.opensips.org/index.php?n=Resources.DocsTsMem
>
> Regards,
> Bogdan
>
> Schumann Sebastian wrote:
> > Hi all
> >
> > I have written a module and after running the proxy for quite some
> > time I get out of pkg mem message.
> >
> > I attached a piece of code how I deal with pkg mem. Please
> let me know
> > if there is something wrong or forgotten respectively.
> >
> > Thanks a lot.
> > Sebastian
> >
> > [snip]
> > n = body_start.len + pres_uri.len + body_middle.len +
> TUPLE_ID_SIZE +
> > body_end.len; s = (char *)pkg_malloc(n); /* as pointers are
> used must
> > not be freed after last use of any reference */
> > if(s==NULL) {
> > LM_ERR("no more pkg mem for body (%d)\n", n);
> > return -1;
> > }
> > p=s;
> > memcpy(p, body_start.s, body_start.len); p += body_start.len;
> > memcpy(p, pres_uri.s, pres_uri.len); p += pres_uri.len; memcpy(p,
> > body_middle.s, body_middle.len); p += body_middle.len; int i;
> > for(i=0;i<TUPLE_ID_SIZE;i++) {
> > *(p++) = tuple[i];
> > }
> >
> > memcpy(p, body_end.s, body_end.len);
> > p += body_end.len;
> > body.s = s;
> > body.len = (int)(p-s);
> >
> > if(body.len > n) {
> > LM_ERR("Buffer size overflow for body\n");
> > pkg_free(s);
> > return -1;
> > }
> > ...
> > pkg_free(s);
> > [snip]
> >
> ----------------------------------------------------------------------
> > --
> >
> > _______________________________________________
> > Devel mailing list
> > Devel at lists.opensips.org
> > http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
> >
>
>
More information about the Devel
mailing list