[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Boxed userdata and garbage collector
- From: Wesley Smith <wesley.hoke@...>
- Date: Thu, 2 Sep 2010 20:02:30 -0500
> while not finished do
> local img = cv.RetrieveFrame(cam) -- retrieves image from cam
> -- do some processing
> end
>
> A full color image takes about 230K, and imagine 15fps - that is a lot
> of data. Yes, I could force the end user to call img:Release() after
> processing, but I want to spare him this step.
>
> Since I cannot force the library to use my custom allocator (and the
> image is allocated inside the library), I have to use boxed userdata,
> containing a pointer to the image - and Lua sees that as only 4/8 bytes,
> which may cause memory problems after some time.
>
>
I've been doing a lot of work with video processing and lua for the past few years and have never had memory problems. Basically you don't want to return a new userdata on each frame, but reuse it and the memory. That way you only have a minimal amount to free.
wes
- References:
- Boxed userdata and garbage collector, Sylvain Fabre
- Re: Boxed userdata and garbage collector, Florian Weimer
- Re: Boxed userdata and garbage collector, Sylvain Fabre
- Re: Boxed userdata and garbage collector, Jonathan Castello
- Re: Boxed userdata and garbage collector, Sylvain Fabre
- Re: Boxed userdata and garbage collector, Jonathan Castello
- Re: Boxed userdata and garbage collector, Ted Unangst
- Re: Boxed userdata and garbage collector, Peter Cawley
- Re: Boxed userdata and garbage collector, Ted Unangst
- Re: Boxed userdata and garbage collector, Peter Cawley
- Re: Boxed userdata and garbage collector, Ted Unangst
- Re: Boxed userdata and garbage collector, Michal Kottman