|
⚛ |
at Dec 5, 2012 at 6:44 pm
|
⇧ |
| |
On Wednesday, December 5, 2012 1:31:33 PM UTC+1, Ryan Slade wrote:
Thanks
Surely you could do this in almost any GC language though?
You can do it in any GC language, but in GC languages like Java it most
likely wouldn't deliver reduced memory consumption nor greater execution
speed.
In my opinion, the mentioned example
http://golang.org/src/pkg/regexp/exec.go#L91 is close to what Rob meant in
the article, but it isn't what he meant. He probably meant to allocate a
linear array of structs and let the custom "2nd order" allocator return
pointers to elements in the array. When the code is done with an element,
the element is sent to the custom "2nd order" memory manager (M) which
appends the element to a free list. When M is created it may pre-populate
the free list, but this isn't strictly required.
In what way does Go make this easier?
In C# and Java it is impossible to get a pointer (type: *T) to any element
of an array (type: [N]T or []T).
My background is mostly C# where it's possible to pass references around,
is this something that's not possible in Java for example?
On Wednesday, 5 December 2012 11:51:46 UTC, Jan Mercl wrote:On Wed, Dec 5, 2012 at 12:46 PM, Ryan Slade wrote:
"As a more direct example, in Go it is easy and efficient to provide
second-order allocators, for instance an arena allocator that allocates a
large array of structs and links them together with a free list. Libraries
that repeatedly use many small structures like this can, with modest
prearrangement, generate no garbage yet be efficient and responsive."
Can anyone give an example / explanation of this?
See for example:
http://golang.org/src/pkg/regexp/exec.go#L91-j
--