Hi,

I'm trying to create a nice api for slurping an io.Reader into memory (if 
size is under threshold), or into a temporary file that's Mmaped.

Everything works, if I give back an explicit io.Closer beside the []byte of 
the data, that Unmaps the []btye region when the caller has finished.

I wanted to get rid of that io.Closer, and use runtime.SetFinalizer(&p,...)

But that p is collected when not in use - even when a subslice is in use!

I've tried to runtime.SetFinalizer(&p[0]),
but that complains that that address is not an allocated - which is 
understandable, as that's allocated by the OS, not by the Go GC.

So, how to Unmap only when all the references of the backing array gets 
garbage collected?

Or any other idea?

Thanks in advance,
Tamás Gulácsi

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/715e3f4e-5ff9-448e-a36a-f9bea601a3afn%40googlegroups.com.

Reply via email to