2012/6/5 Jan Kanis <jan.c...@jankanis.nl>
 ...

>
>
>> Maybe I should have documented the code better, then. I really think it's
>> a pretty wonderful idea, and pretty much the nicest memory management model
>> you can find in languages without garbage collecting, IMO. Not my idea at
>> all, though. I got it from a very similar setup used by the samba project,
>> but the idea's been around for a lot longer than that. I rolled my own
>> version because I wanted to be able to call methods when deallocating, sort
>> of like a destructor in C++, which wasn't possible in the samba version.
>>
>
> Obviously I haven't looked into fish's memory management enough to notice
> that. Is there a writeup of these ideas anywhere online other than reading
> the code?
>
>
It's a pretty simple idea, when you allocate a block of memory, you can
pass in a previous memory allocation into that allocation. If you do, then
when the previous allocation gets free'd, your own allocation will also go
the way of the dodo. That's pretty much it.

In fish, there are lots of allocations that are only relevant to a specific
job, and once that job finishes, there is no longer any need for the
memory. All those allocations could just use the job as the context, and
one would never need to worry about when to free what.

A lot of applications have predefined lifetimes like that, once you start
to think about it. I guess one could say it's a bit like an auto_ptr in
C++. Except different. :-)

Axel
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to