lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> 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