[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Boxed userdata and garbage collector
- From: Ted Unangst <ted.unangst@...>
- Date: Thu, 2 Sep 2010 16:37:52 -0400
On Thu, Sep 2, 2010 at 4:30 PM, Jonathan Castello <email@example.com> wrote:
> On Thu, Sep 2, 2010 at 1:27 PM, Ted Unangst <firstname.lastname@example.org> wrote:
>> What happens when you resize an image? You need to allocate more
>> memory. You can't modify all the Lua references to the old image, so
>> you need the Lua refs to be shallow pointers to the real data. And
>> allocating the real data as userdata too, and then hanging a reference
>> to it, gets to be a pain. You could make all operations return new
>> images, but that's quite inefficient.
> Hmm, see, since the OP said that they were using a "structure", I
> assumed the userdatum was not the image itself but rather a structure
> containing a pointer to an image.
That's exactly the interpretation I had. The idea is that the current
shallow userdatum allows swapping out the heavy data. Moving the
heavy data into the userdatum has a number of drawbacks.