On Fri, Mar 6, 2020 at 4:55 PM Christophe Meessen < christophe.mees...@gmail.com> wrote:
> It would have been convenient for detecting memory leaks to be able to compare memory Alloc before and after the checked task and a really complete GC. That's not feasible. There are _always_ other runtime-started goroutines running during execution of a program and they may allocate memory in no predictable pattern. Here's a sample run with Go 1.14 on Linux/amd64 (with added time stamps). jnml@e5-1650:~/tmp/gc> date ; ./gc Fri Mar 6 17:10:55 CET 2020 2020-03-06 17:11:15.47671116 +0100 CET m=+20.000226110 status: memUsed: 140296 allocs: 155 numGC 0 2020-03-06 17:11:35.476718873 +0100 CET m=+40.000234661 status: memUsed: 155376 allocs: 191 numGC 1 2020-03-06 17:11:55.476670923 +0100 CET m=+60.000185942 status: memUsed: 157248 allocs: 197 numGC 2 2020-03-06 17:12:15.476638267 +0100 CET m=+80.000153357 status: memUsed: 157264 allocs: 199 numGC 3 2020-03-06 17:12:35.476746762 +0100 CET m=+100.000262341 status: memUsed: 157264 allocs: 199 numGC 4 2020-03-06 17:12:55.476724863 +0100 CET m=+120.000240581 status: memUsed: 157280 allocs: 201 numGC 5 2020-03-06 17:13:15.476737116 +0100 CET m=+140.000252973 status: memUsed: 157280 allocs: 201 numGC 6 2020-03-06 17:13:35.476650054 +0100 CET m=+160.000165143 status: memUsed: 157376 allocs: 202 numGC 7 2020-03-06 17:13:55.476609855 +0100 CET m=+180.000124805 status: memUsed: 157376 allocs: 202 numGC 8 2020-03-06 17:14:15.476707245 +0100 CET m=+200.000222544 status: memUsed: 157472 allocs: 203 numGC 9 2020-03-06 17:14:35.47665699 +0100 CET m=+220.000172009 status: memUsed: 157568 allocs: 204 numGC 10 2020-03-06 17:14:55.476618049 +0100 CET m=+240.000133068 status: memUsed: 157776 allocs: 207 numGC 11 2020-03-06 17:15:15.476615426 +0100 CET m=+260.000130515 status: memUsed: 157768 allocs: 206 numGC 12 2020-03-06 17:15:35.476601977 +0100 CET m=+280.000116926 status: memUsed: 157768 allocs: 206 numGC 13 2020-03-06 17:15:55.476594814 +0100 CET m=+300.000109833 status: memUsed: 159528 allocs: 210 numGC 14 2020-03-06 17:16:15.476613143 +0100 CET m=+320.000128162 status: memUsed: 159528 allocs: 210 numGC 15 2020-03-06 17:16:35.476656056 +0100 CET m=+340.000171146 status: memUsed: 159528 allocs: 210 numGC 16 2020-03-06 17:16:55.476664258 +0100 CET m=+360.000179278 status: memUsed: 159528 allocs: 210 numGC 17 2020-03-06 17:17:15.476620428 +0100 CET m=+380.000135448 status: memUsed: 159528 allocs: 210 numGC 18 ^C jnml@e5-1650:~/tmp/gc> As can be seen above, eventually the allocated memory goes down and stabilizes, as predicted by Volker. -- 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/CAA40n-VEE15R9Lgpaq5RYAAb%3D6nwqOAx9UCgRL9A-B%3D1Lnc7eA%40mail.gmail.com.