Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1867)

Delta Between Two Patch Sets: src/pkg/runtime/malloc.goc

Issue 69870055: code review 69870055: runtime: fix runaway memory usage (Closed)
Left Patch Set: Created 11 years ago
Right Patch Set: diff -r 7a45730704af https://dvyukov%40google.com@code.google.com/p/go/ Created 11 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/runtime/mcache.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // See malloc.h for overview. 5 // See malloc.h for overview.
6 // 6 //
7 // TODO(rsc): double-check stats. 7 // TODO(rsc): double-check stats.
8 8
9 package runtime 9 package runtime
10 #include "runtime.h" 10 #include "runtime.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } else { 322 } else {
323 // Small object. 323 // Small object.
324 if(size > 2*sizeof(uintptr)) 324 if(size > 2*sizeof(uintptr))
325 ((uintptr*)v)[1] = (uintptr)0xfeedfeedfeedfeedll; // mark as "needs to be zeroed" 325 ((uintptr*)v)[1] = (uintptr)0xfeedfeedfeedfeedll; // mark as "needs to be zeroed"
326 else if(size > sizeof(uintptr)) 326 else if(size > sizeof(uintptr))
327 ((uintptr*)v)[1] = 0; 327 ((uintptr*)v)[1] = 0;
328 // Must mark v freed before calling MCache_Free: 328 // Must mark v freed before calling MCache_Free:
329 // it might coalesce v and other blocks into a bigger span 329 // it might coalesce v and other blocks into a bigger span
330 // and change the bitmap further. 330 // and change the bitmap further.
331 c->local_nsmallfree[sizeclass]++; 331 c->local_nsmallfree[sizeclass]++;
332 c->local_cachealloc -= size;
332 if(c->alloc[sizeclass] == s) { 333 if(c->alloc[sizeclass] == s) {
333 // We own the span, so we can just add v to the freelist 334 // We own the span, so we can just add v to the freelist
334 runtime·markfreed(v); 335 runtime·markfreed(v);
335 ((MLink*)v)->next = s->freelist; 336 ((MLink*)v)->next = s->freelist;
336 s->freelist = v; 337 s->freelist = v;
337 s->ref--; 338 s->ref--;
338 } else { 339 } else {
339 // Someone else owns this span. Add to free queue. 340 // Someone else owns this span. Add to free queue.
340 runtime·MCache_Free(c, v, sizeclass, size); 341 runtime·MCache_Free(c, v, sizeclass, size);
341 } 342 }
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // NOTE: asking to remove a finalizer when there currently isn't one set is OK. 883 // NOTE: asking to remove a finalizer when there currently isn't one set is OK.
883 runtime·removefinalizer(obj.data); 884 runtime·removefinalizer(obj.data);
884 } 885 }
885 return; 886 return;
886 887
887 badfunc: 888 badfunc:
888 runtime·printf("runtime.SetFinalizer: cannot pass %S to finalizer %S\n", *obj.type->string, *finalizer.type->string); 889 runtime·printf("runtime.SetFinalizer: cannot pass %S to finalizer %S\n", *obj.type->string, *finalizer.type->string);
889 throw: 890 throw:
890 runtime·throw("runtime.SetFinalizer"); 891 runtime·throw("runtime.SetFinalizer");
891 } 892 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b