FAQ
Universal -- Can allocate a memory block of any size which then will be
used for values of any type with that size.
Fast -- It preallocates chunks of memory blocks and then give it
away instead of actual allocation.
gc support -- It supports standard golang's gc and free memory chunks when
all memory blocks of that chunk are not referenced anywhere(except memory
chunk itself), so you don't need C-style free(my_memory).

Is it possible to write something like that in golang? So far I came to
conclusion that such memory allocator could be written for particular type
with some special modifications of code(like simulating weakrefs with
embedded pointer
https://groups.google.com/d/msg/golang-nuts/1ItNOOj8yW8/9xBlzy6DNKYJ ) so
functions that operate on that type must be rewritten to be aware of
embedded pointer(but I'm unsure on this method). Or such allocator could be
written, but with C-style 'free' function.

Am I wrong? Or do you have some ideas on topic(maybe some tricks using
runtime,unsafe or cgo)?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dmitry Vyukov at Jan 2, 2014 at 1:51 pm

    On Thu, Jan 2, 2014 at 5:36 PM, Constantin Kulikov wrote:
    Universal -- Can allocate a memory block of any size which then will be
    used for values of any type with that size.
    Fast -- It preallocates chunks of memory blocks and then give it
    away instead of actual allocation.
    gc support -- It supports standard golang's gc and free memory chunks when
    all memory blocks of that chunk are not referenced anywhere(except memory
    chunk itself), so you don't need C-style free(my_memory).

    Is it possible to write something like that in golang? So far I came to
    conclusion that such memory allocator could be written for particular type
    with some special modifications of code(like simulating weakrefs with
    embedded pointer
    https://groups.google.com/d/msg/golang-nuts/1ItNOOj8yW8/9xBlzy6DNKYJ ) so
    functions that operate on that type must be rewritten to be aware of
    embedded pointer(but I'm unsure on this method). Or such allocator could be
    written, but with C-style 'free' function.

    Am I wrong? Or do you have some ideas on topic(maybe some tricks using
    runtime,unsafe or cgo)?

    Yes, it's possible, and it's already done. It is the standard Go
    memory allocator. So if you just do not do anything special, you get
    all the properties you want.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Constantin Kulikov at Jan 2, 2014 at 2:04 pm
    It is the standard Go memory allocator.
    And pprof shows malloc on top of it's statistics.
    Well done standard Go memory allocator. :)


    четверг, 2 января 2014 г., 17:50:48 UTC+4 пользователь Dmitry Vyukov
    написал:
    Yes, it's possible, and it's already done. It is the standard Go
    memory allocator. So if you just do not do anything special, you get
    all the properties you want.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dmitry Vyukov at Jan 2, 2014 at 2:14 pm

    On Thu, Jan 2, 2014 at 6:04 PM, Constantin Kulikov wrote:
    It is the standard Go memory allocator.
    And pprof shows malloc on top of it's statistics.
    Well done standard Go memory allocator. :)
    Top position means nothing. It's easy to bring something to top by
    combining several functions. It's also easy to bring something down by
    splitting it into several functions.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 2, '14 at 1:36p
activeJan 2, '14 at 2:14p
posts4
users2
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase