Luabind memory leak

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Luabind memory leak

Luis Villegas

I was tracking down a memory look for my Masters project and ran into the following situation:

 

Luabind uses a class function_rep for encapsulating data for specific functions.

 

Function_rep looks something like:

 

Class function_rep

{

// blablabla

std::vector<blablabla> m_overrides;

}

 

 

Instances of this class are managed by lua by using luauserdata.  So at some point in the code:

 

Luauserdatanew(function_rep_instance, sizeof(function_rep_instance));

 

I think the promise is that Lua will clean up the memory when is closed, the problem is that lua performs a free on the memory, but since Lua knows nothing about the type of object the cleanup is not accurate, and the data help by m_overrides is never freed.

 

Is Luabind still being actively developed?

If so, is this the right place to report bugs?

 

Thank you,

Luis Villegas

Reply | Threaded
Open this post in threaded view
|

RE: Luabind memory leak

Korval
I'm kinda surprised that nobody's answered you by now.
 
In any case, yes, LuaBind is actively being developed. Indeed, by the tone of your question, I imagine that you aren't aware that they made a new release of LuaBind last week. You may want to try to work with that and see if it fixes the leak.
-----Original Message-----
From: [hidden email] [mailto:[hidden email]]On Behalf Of Luis Villegas
Sent: Tuesday, January 31, 2006 10:17 AM
To: [hidden email]
Subject: [luabind] Luabind memory leak

I was tracking down a memory look for my Masters project and ran into the following situation:

 

Luabind uses a class function_rep for encapsulating data for specific functions.

 

Function_rep looks something like:

 

Class function_rep

{

// blablabla

std::vector<blablabla> m_overrides;

}

 

 

Instances of this class are managed by lua by using luauserdata.  So at some point in the code:

 

Luauserdatanew(function_rep_instance, sizeof(function_rep_instance));

 

I think the promise is that Lua will clean up the memory when is closed, the problem is that lua performs a free on the memory, but since Lua knows nothing about the type of object the cleanup is not accurate, and the data help by m_overrides is never freed.

 

Is Luabind still being actively developed?

If so, is this the right place to report bugs?

 

Thank you,

Luis Villegas

Reply | Threaded
Open this post in threaded view
|

RE: Luabind memory leak

Arvid Norberg
Quoting Korval <[hidden email]>:

> I'm kinda surprised that nobody's answered you by now.
>
> In any case, yes, LuaBind is actively being developed. Indeed, by the tone
> of your question, I imagine that you aren't aware that they made a new
> release of LuaBind last week. You may want to try to work with that and see
> if it fixes the leak.
>   -----Original Message-----
>   From: [hidden email]
> [mailto:[hidden email]]On Behalf Of Luis Villegas
>   Sent: Tuesday, January 31, 2006 10:17 AM
>   To: [hidden email]
>   Subject: [luabind] Luabind memory leak
>
>
>   I was tracking down a memory look for my Masters project and ran into the
> following situation:
>
>
>
>   Luabind uses a class function_rep for encapsulating data for specific
> functions.
>
>   Function_rep looks something like:
>
>   Class function_rep
>   {
>   // blablabla
>   std::vector<blablabla> m_overrides;
>   }
>
>
>   Instances of this class are managed by lua by using luauserdata.  So at
> some point in the code:
>
>   Luauserdatanew(function_rep_instance, sizeof(function_rep_instance));
>
>   I think the promise is that Lua will clean up the memory when is closed,
> the problem is that lua performs a free on the memory, but since Lua knows
> nothing about the type of object the cleanup is not accurate, and the data
> help by m_overrides is never freed.

luabind registers a metatable with a __gc function wich is called by lua right
before the object is deleted by lua. In there the destructor is called.

>   Is Luabind still being actively developed?

Yep.

>   If so, is this the right place to report bugs?

Yes it is.


--
Arvid Norberg


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

RE: Luabind memory leak

Luis Villegas
Thanks for the information,

Based on the crt debug memory tracker (For VS2003) that memory is not
getting released, and by following the code path it does not seem like
the destructor is being called at all.  I might be doing something wrong
or misunderstanding the issue, I will try to follow the code path again
to verify that the destructor is indeed getting called and will report
back.

I will also try the latest release.

Thanks again
Luis Villegas

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of
[hidden email]
Sent: Saturday, February 04, 2006 1:15 AM
To: [hidden email]
Subject: RE: [luabind] Luabind memory leak

Quoting Korval <[hidden email]>:
> I'm kinda surprised that nobody's answered you by now.
>
> In any case, yes, LuaBind is actively being developed. Indeed, by the
tone
> of your question, I imagine that you aren't aware that they made a new
> release of LuaBind last week. You may want to try to work with that
and see
> if it fixes the leak.
>   -----Original Message-----
>   From: [hidden email]
> [mailto:[hidden email]]On Behalf Of Luis
Villegas
>   Sent: Tuesday, January 31, 2006 10:17 AM
>   To: [hidden email]
>   Subject: [luabind] Luabind memory leak
>
>
>   I was tracking down a memory look for my Masters project and ran
into the
> following situation:
>
>
>
>   Luabind uses a class function_rep for encapsulating data for
specific

> functions.
>
>   Function_rep looks something like:
>
>   Class function_rep
>   {
>   // blablabla
>   std::vector<blablabla> m_overrides;
>   }
>
>
>   Instances of this class are managed by lua by using luauserdata.  So
at
> some point in the code:
>
>   Luauserdatanew(function_rep_instance,
sizeof(function_rep_instance));
>
>   I think the promise is that Lua will clean up the memory when is
closed,
> the problem is that lua performs a free on the memory, but since Lua
knows
> nothing about the type of object the cleanup is not accurate, and the
data
> help by m_overrides is never freed.

luabind registers a metatable with a __gc function wich is called by lua
right
before the object is deleted by lua. In there the destructor is called.

>   Is Luabind still being actively developed?

Yep.

>   If so, is this the right place to report bugs?

Yes it is.


--
Arvid Norberg


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642">http://sel.as-us.falkag.net/sel?cmd=k&kid3432&bid#0486&dat1642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Luabind memory leak

Arvid Norberg
On Feb 5, 2006, at 23:17, Luis Villegas wrote:

> Thanks for the information,
>
> Based on the crt debug memory tracker (For VS2003) that memory is not
> getting released, and by following the code path it does not seem like
> the destructor is being called at all.  I might be doing something  
> wrong
> or misunderstanding the issue, I will try to follow the code path  
> again
> to verify that the destructor is indeed getting called and will report
> back.
>
> I will also try the latest release.

Oh. There was a known memory leak in beta 6 when registering  
functions. It was fixed a long time ago though (only on cvs until  
quite recently though).

--
Arvid Norberg




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user