FAQ
Okay, so this isn't necessarily about Go however Go is garbage collected so
it does pertain to Go programs.

I have been listening to talks on a few different topics because I am
researching the best technology I could use for my various client/server
needs and I came across what I think may be a great idea to orient programs
towards. Now I am not a professional developer and I am not sure about many
common practices but bear with me and please leave feedback.

So, we are garbage collected. We live in a world of memory that gets
reallocated over and over, but at what cost? It obviously imposes speed and
efficiency issues, why let GC take control of my program to clean up my
mess? It less obviously limits overall computing power by putting stress on
other running programs to handle memory surges from careless allocation.

Can we think of a better way? Have we already done it? What about stacks
and unchanging storage?
Let's say I have use seven arrays, the largest of which was 100 bytes. We
only ever need two at a time in any function in our program and only one of
them stores persistent data. We can define one to hold the persistent data
and two for temporary data.

arrPerm := make([]byte, 100)
arrTempA := make([]byte, 100)
intTempABound := 100
arrTempB := make([]byte, 100)
intTempBBound := 100 // These bound ints are for checking a bound that is
lower if we don't need all 100 bytes

getInput(arrPerm) //An input function that puts our needed data in the
persistent storage.
func sort(input, tempA, tempB []byte) {
push(tempA)
defer pop(tempA)
push(tempB)
defer pop(tempA)
// Sort operations
return
}


This is an overly simple example but what do you think?

--
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

  • Kyle Lemons at Feb 14, 2013 at 4:46 pm
    I'm not sure what you are suggesting; yes, if you are finding that your
    program is generating too much garbage, you should work on either creating
    less of it or using a pool allocator of some sort. In general, though, in
    a concurrent program it is difficult to know who is responsible for
    cleaning up an object and putting it back into the pool. That's why Go is
    garbage collected: if it were easy to do it yourself, it wouldn't be
    necessary.

    On Wed, Feb 13, 2013 at 5:39 PM, Steven Rice wrote:

    Okay, so this isn't necessarily about Go however Go is garbage collected
    so it does pertain to Go programs.

    I have been listening to talks on a few different topics because I am
    researching the best technology I could use for my various client/server
    needs and I came across what I think may be a great idea to orient programs
    towards. Now I am not a professional developer and I am not sure about many
    common practices but bear with me and please leave feedback.

    So, we are garbage collected. We live in a world of memory that gets
    reallocated over and over, but at what cost? It obviously imposes speed and
    efficiency issues, why let GC take control of my program to clean up my
    mess? It less obviously limits overall computing power by putting stress on
    other running programs to handle memory surges from careless allocation.

    Can we think of a better way? Have we already done it? What about stacks
    and unchanging storage?
    Let's say I have use seven arrays, the largest of which was 100 bytes. We
    only ever need two at a time in any function in our program and only one of
    them stores persistent data. We can define one to hold the persistent data
    and two for temporary data.

    arrPerm := make([]byte, 100)
    arrTempA := make([]byte, 100)
    intTempABound := 100
    arrTempB := make([]byte, 100)
    intTempBBound := 100 // These bound ints are for checking a bound that is
    lower if we don't need all 100 bytes

    getInput(arrPerm) //An input function that puts our needed data in the
    persistent storage.
    func sort(input, tempA, tempB []byte) {
    push(tempA)
    defer pop(tempA)
    push(tempB)
    defer pop(tempA)
    // Sort operations
    return
    }


    This is an overly simple example but what do you think?

    --
    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.

    --
    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
postedFeb 14, '13 at 1:39a
activeFeb 14, '13 at 4:46p
posts2
users2
websitegolang.org

2 users in discussion

Steven Rice: 1 post Kyle Lemons: 1 post

People

Translate

site design / logo © 2022 Grokbase