Re: [go-nuts] Why golang allocated memory space increases?

2020-03-25 Thread steve tang
lly at any time without > 18 // notification. If the Pool holds the only reference when this > happens, the19 // item might be deallocated. > > So placing an object in the pool does not guarantee it won’t be collected > - causing a future allocation. > > On Mar 25, 2020, a

[go-nuts] Why golang allocated memory space increases?

2020-03-25 Thread steve tang
chunkCrc32Hash := crc32.NewIEEE() chunkBuf := bufferpool.GetInstance().Get() //回收buffer defer bufferpool.GetInstance().Put(chunkBuf) writer := io.MultiWriter(chunkBuf, chunkCrc32Hash) _, copyErr := io.Copy(writer, chunkResp.RawResponse.Body) if copyErr != nil && copyErr != io.EOF { logmgr.ErrorL

[go-nuts] Re: Concurrency and order of execution

2016-11-15 Thread steve tang
There is not any guarentee in your goroutine, But you could try it as:https://play.golang.org/p/JDRAP4mxdc On Friday, November 11, 2016 at 2:08:39 PM UTC+8, mspaul...@gmail.com wrote: > > Hello, > > I've written a small program to demonstrate what I am seeing. If I use a > channel as a semap

Re: [go-nuts] How to conv [3]int to []int ?

2016-11-11 Thread steve tang
t; The code that is generated is exactly the same for both (you can check > this with go tool compile -S). > > On Thu, 2016-11-10 at 23:46 -0800, steve tang wrote: > > Thanks, But I want them hold same data addrs. So I just changed > > your code > > to follows:

Re: [go-nuts] How to conv [3]int to []int ?

2016-11-10 Thread steve tang
main > > import ( > "fmt" > ) > > func main() { > a := [3]int{1, 2, 3} > b := a[:] > fmt.Println(b) > } > > https://play.golang.org/p/OBY7g3azBE > > If so, there's no need for unsafe. If not, what are y

[go-nuts] How to conv [3]int to []int ?

2016-11-10 Thread steve tang
Hi theres, I used unsafe.Pointer to conv Type [3]int to Type []int, But it throws a runtime error, Could anybody tell me why? many thanks. The test code is as follows: package main import ( "fmt" "unsafe" ) func main() { a := [3]int{1, 2, 3} b := *(*[]int)(unsafe.Pointer(&a)) fmt.Print