Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Dev

vmod memory allocation problem

 

 

Varnish dev RSS feed   Index | Next | Previous | View Threaded


flygoast at 126

May 19, 2013, 1:59 AM

Post #1 of 4 (161 views)
Permalink
vmod memory allocation problem

hi, guys,

I'm newbie in varnish vmod development.

I'am comfusing when I return a char * pointting to a block of memory malloced from heap, Whether resultting in a memory leak?

Such as:

char *

vmod_foo(struct sess *sp, struct vmod_priv *priv)

{

return strdup("foo");

}

Thank you!


jammy.linux at gmail

May 19, 2013, 7:25 PM

Post #2 of 4 (148 views)
Permalink
Re: vmod memory allocation problem [In reply to]

Yes, it will result in memory leakage.

I recommend to use WS_Reserve to allocate your memory within your VMOD.

Best regards


On 19 May, 2013, at 4:59 PM, flygoast wrote:

> hi, guys,
>
> I'm newbie in varnish vmod development.
>
> I'am comfusing when I return a char * pointting to a block of memory malloced from heap, Whether resultting in a memory leak?
>
> Such as:
>
> char *
>
> vmod_foo(struct sess *sp, struct vmod_priv *priv)
>
> {
>
> return strdup("foo");
>
> }
>
> Thank you!
>
>
>
> _______________________________________________
> varnish-dev mailing list
> varnish-dev [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

----------------------------------
Best wishes,
Jammy


drwilco at drwilco

May 19, 2013, 10:09 PM

Post #3 of 4 (147 views)
Permalink
Re: vmod memory allocation problem [In reply to]

Or WS_Alloc if you know how much you need to allocate beforehand.
On May 19, 2013 7:26 PM, "Jammy" <jammy.linux [at] gmail> wrote:

>
> Yes, it will result in memory leakage.
>
> I recommend to use WS_Reserve to allocate your memory within your VMOD.
>
> Best regards
>
>
> On 19 May, 2013, at 4:59 PM, flygoast wrote:
>
> hi, guys,
>
> I'm newbie in varnish vmod development.
>
> I'am comfusing when I return a char * pointting to a block of memory
> malloced from heap, Whether resultting in a memory leak?
>
> Such as:
>
> char *
>
> vmod_foo(struct sess *sp, struct vmod_priv *priv)
>
> {
>
> return strdup("foo");
>
> }
>
> Thank you!
>
>
> _______________________________________________
> varnish-dev mailing list
> varnish-dev [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
>
>
> ----------------------------------
> Best wishes,
> Jammy
>
>
>
>
>
>
>
> _______________________________________________
> varnish-dev mailing list
> varnish-dev [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
>


dridi.boukelmoune at zenika

May 21, 2013, 11:06 AM

Post #4 of 4 (146 views)
Permalink
Re: vmod memory allocation problem [In reply to]

Hi,

For some reason I've missed your question.

I wrote a bit about that, I hope this will help:
http://blog.zenika.com/index.php?post/2012/08/21/Creating-a-Varnish-module

Cheers,
Dridi


On Mon, May 20, 2013 at 7:09 AM, Rogier 'DocWilco' Mulhuijzen
<drwilco [at] drwilco> wrote:
> Or WS_Alloc if you know how much you need to allocate beforehand.
>
> On May 19, 2013 7:26 PM, "Jammy" <jammy.linux [at] gmail> wrote:
>>
>>
>> Yes, it will result in memory leakage.
>>
>> I recommend to use WS_Reserve to allocate your memory within your VMOD.
>>
>> Best regards
>>
>>
>> On 19 May, 2013, at 4:59 PM, flygoast wrote:
>>
>> hi, guys,
>>
>> I'm newbie in varnish vmod development.
>>
>> I'am comfusing when I return a char * pointting to a block of memory
>> malloced from heap, Whether resultting in a memory leak?
>>
>> Such as:
>>
>> char *
>>
>> vmod_foo(struct sess *sp, struct vmod_priv *priv)
>>
>> {
>>
>> return strdup("foo");
>>
>> }
>>
>> Thank you!
>>
>>
>>
>> _______________________________________________
>> varnish-dev mailing list
>> varnish-dev [at] varnish-cache
>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
>>
>>
>> ----------------------------------
>> Best wishes,
>> Jammy
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> varnish-dev mailing list
>> varnish-dev [at] varnish-cache
>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
>
>
> _______________________________________________
> varnish-dev mailing list
> varnish-dev [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

_______________________________________________
varnish-dev mailing list
varnish-dev [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Varnish dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.