Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is the added memory? #33684

Closed
zhaoya881010 opened this issue Aug 16, 2019 · 1 comment

Comments

@zhaoya881010
Copy link

commented Aug 16, 2019

go version 1.12.1 win 32bit

Increase the memory when program is processing data,it may normal.but i found more than 15M after it idle. i don't know Where to spend. I waited long and it's no gc.

pprof heap:

0: 0 [200: 1600716800] @ 0x747b6a 0x7482de 0x7484f2 0x42d527 0x454571
#	0x747b69	main.ReadData+0x69	/go/src/sftp/test/test.go:85
#	0x7482dd	main.dataParser+0xcd	/go/src/sftp/test/test.go:124
#	0x7484f1	main.main+0xf1		go/src/sftp/test/test.go:172
#	0x42d526	runtime.main+0x1d6	C:/Go/src/runtime/proc.go:200

0: 0 [200: 1600716800] @ 0x747b41 0x7482de 0x7484f2 0x42d527 0x454571
#	0x747b40	main.ReadData+0x40	/go/src/sftp/test/test.go:84
#	0x7482dd	main.dataParser+0xcd	/go/src/sftp/test/test.go:124
#	0x7484f1	main.main+0xf1		       /go/src/sftp/test/test.go:172
#	0x42d526	runtime.main+0x1d6	C:/Go/src/runtime/proc.go:200

# runtime.MemStats
# Alloc = 7569496
# TotalAlloc = 28812262064
# Sys = 143129724
# Lookups = 0
# Mallocs = 1200030521
# Frees = 1200026994
# HeapAlloc = 7569496
# HeapSys = 129662976
# HeapIdle = 121389056
# HeapInuse = 8273920
# HeapReleased = 121389056
# HeapObjects = 3527
# Stack = 360448 / 360448
# MSpan = 11880 / 1146880
# MCache = 3440 / 16384
# BuckHashSys = 724589
# GCSys = 10340352
# OtherSys = 878095
# NextGC = 15100688
# LastGC = 156595974683963720

uuidASlice and uuidBSlice is on the heap.

func ReadData(db *sql.DB, table string) ([]string, []string, error) {
	uuidASlice := make([]string, 0, 1000000)    -----------------------------line 84
	uuidBSlice := make([]string, 0, 1000000)    -----------------------------line 85
	command := fmt.Sprintf(`select "uuida","uuidb" from "%s"`, table)
	starttime := time.Now()
	rows, err := db.Query(command)
	if err != nil {
		log.Fatal(err)
	}
	for rows.Next() {
		var data1  string
		var data2  string
		if err := rows.Scan(&data1,&data2); err != nil {
			oci8.OCI8Driver.Logger.Fatal(err)
		}
		uuidASlice = append(uuidASlice, data1)
		uuidBSlice = append(uuidBSlice, data2)
	}

	log.Printf("read data uuida:%f,uuidb:%d,s:%d:\n", time.Now().Sub(starttime).Seconds(), len(uuidASlice), len(uuidBSlice))
	debug.FreeOSMemory()
	return nil, nil, err
}
@andybons

This comment has been minimized.

Copy link
Member

commented Aug 16, 2019

Hi there,

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For asking questions, see:

Please ask the question on one of the above forums.

(Quoted from https://golang.org/wiki/Questions)

@andybons andybons closed this Aug 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.