cURL / Mailing Lists / curl-library / Single Mail


Re: How do I free the memory used by an in-memory, non-formdata post request? (HeapValidate exception)

From: Daniel Stenberg <>
Date: Mon, 11 Oct 2010 21:15:53 +0200 (CEST)

On Mon, 11 Oct 2010, Ola Mork wrote:

> Everything functions as expected. My problem is that after I've called
> curl_easy_perform the address of my _request.memory changes and I can no
> longer safely free it. I get a HeapValidate exception because libcurl
> changes the address to somewhere in not-my-memory-space.

No, libcurl doesn't touch your struct. libcurl passes on the pointer that you
tell it to pass on, everything else is your app doing what it wants to do.

> What is the correct way to free _request.memory?

That's your application's work.

> Is it already free'd by curl and I don't need to worry about it?

curl cannot free it, it doesn't even know what you allocated anything and it
doesn't even know about _request.memory's existance.

> I'd rather not call curl_global_cleanup after every single request.

That wouldn't even solve anything.

> I discovered this using libcurl 7.16.4 but it's apparent in 7.21.1 too.

This is not a flaw in libcurl...

List admin:
Received on 2010-10-11