Re: Projects I may be willing to sponsor

  • From: Joe Ellsworth <joexdobs@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 11 Dec 2014 07:41:14 -0800

I think what you have shown is adequate. I will let you know after I port some code over to use it.

On 12/11/2014 3:00 AM, Mike Pall wrote:
Stefano wrote:
Well, wrapping it in a struct with a __gc metamethod is automatic enough
for me....or am I missing something?
That's unlikely to work well, if the referenced chunk of memory is
very large. The GC only sees the small memory pool it manages
(e.g. a few MB) and the tiny structs themselves (e.g. 50 bytes).

Now, even if you attach a 10 gigabyte piece of memory to each
struct, the GC has no incentive to drive the collector forward.
You run out of memory after 8 allocations at 8*10 = 80 gigabytes.
But the GC only sees 8*50 = 400 bytes and doesn't bother.

Even if there was some way to tell the GC about that 'other'
memory, the (incremental) GC will see the memory pressure after
the first 10 GB allocation, but it could never catch up at that
pace or that granularity relative to the total amount of memory.
The only recourse would be to run a full GC after every huge
allocation. But that would destroy performance, anyway.

Automatic GC is nice, but not a panacea.

--Mike



Other related posts: