Re: [go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread Piotr Narewski
:-) I see what you mean, but unfortunately I cannot put it back just yet.. ;-) But the whole idea is a good thing to explore. Most of the data chunks I use have certain sizes - perhaps I can sort them into some groups hold by separate pools. I'm going to look int this kind of solution. Thank

Re: [go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread Jan Mercl
On Wed, May 3, 2017 at 6:50 PM Piotr Narewski wrote: > Perhaps that is the reason; when I need 515 bytes, it actually allocates 1024 > This might be when I'm loosing the mem. Not if you Put() it back after use ;-) It's of course also possible to make the allocation

Re: [go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread Jan Mercl
On Wed, May 3, 2017 at 6:39 PM Piotr Narewski wrote: > I am supposed to allocate the slice with "slice.Bytes.Get(515).(*[]byte)" not "make([]byte, 515)" Yes. Even better is p := slice.Bytes.Get(n) b := *p ... use b as usual, it's already a []byte.

Re: [go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread Piotr Narewski
Yes. Perhaps that is the reason; when I need 515 bytes, it actually allocates 1024 This might be when I'm loosing the mem. On Wednesday, May 3, 2017 at 6:47:53 PM UTC+2, Jan Mercl wrote: > > On Wed, May 3, 2017 at 6:28 PM Piotr Narewski > wrote: > > > I've checked it and I

Re: [go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread Jan Mercl
On Wed, May 3, 2017 at 6:28 PM Piotr Narewski wrote: > I've checked it and I think there is something wrong with this lib. I haven't checked thoroughly, but it seems to be working as intended. If you Put(515) the correct bin to use is the one for sizes 257-512. If you

Re: [go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread Piotr Narewski
No sorry - I think I did not do it right. I am supposed to allocate the slice with "slice.Bytes.Get(515).(*[]byte)" not "make([]byte, 515)" In which case I still don't know why it's eating up my mem... :) On Wednesday, May 3, 2017 at 6:28:20 PM UTC+2, Piotr Narewski wrote: > > Thanks. > > I've

Re: [go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread Piotr Narewski
Thanks. I've checked it and I think there is something wrong with this lib. If I do: dat := make([]byte, 515) slice.Bytes.Put() println(dat) And then: p := slice.Bytes.Get(515).(*[]byte) println(*p) It returns me a different slice. To get the same slice, I need to go down from 515 to 512

Re: [go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread Jan Mercl
On Wed, May 3, 2017 at 4:24 PM Piotr Narewski wrote: > I've just tried it and unfortunately it doesn't seem to be better than the traditional approach. > > With the pool in place, it still user too much memory (unlike my solution with using a heap via glibc). Sorry to hear

[go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread Piotr Narewski
OK, I get it. I've just tried it and unfortunately it doesn't seem to be better than the traditional approach. With the pool in place, it still user too much memory (unlike my solution with using a heap via glibc). Anyway, thanks - it was worth trying. On Wednesday, May 3, 2017 at 3:33:12 PM

[go-nuts] Re: Is there a way to fee a memory object on demand?

2017-05-03 Thread T L
It would be great if it is possible that the collector only collect a specified memory block groups. For example, runtime.GC(group []unsafe.Pointer), will only collect the memory blocks only referenced by the group parameter. On Wednesday, May 3, 2017 at 2:35:43 AM UTC+8, Piotr Narewski wrote: