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

Side by Side Diff: src/pkg/runtime/mcache.c

Issue 69870055: code review 69870055: runtime: fix runaway memory usage (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/malloc.goc ('k') | src/pkg/runtime/mgc0.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Per-P malloc cache for small objects. 5 // Per-P malloc cache for small objects.
6 // 6 //
7 // See malloc.h for an overview. 7 // See malloc.h for an overview.
8 8
9 #include "runtime.h" 9 #include "runtime.h"
10 #include "arch_GOARCH.h" 10 #include "arch_GOARCH.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 void 90 void
91 runtime·MCache_Free(MCache *c, MLink *p, int32 sizeclass, uintptr size) 91 runtime·MCache_Free(MCache *c, MLink *p, int32 sizeclass, uintptr size)
92 { 92 {
93 MCacheList *l; 93 MCacheList *l;
94 94
95 // Put on free list. 95 // Put on free list.
96 l = &c->free[sizeclass]; 96 l = &c->free[sizeclass];
97 p->next = l->list; 97 p->next = l->list;
98 l->list = p; 98 l->list = p;
99 l->nlist++; 99 l->nlist++;
100 c->local_cachealloc -= size;
101 100
102 // We transfer a span at a time from MCentral to MCache, 101 // We transfer a span at a time from MCentral to MCache,
103 // so we'll do the same in the other direction. 102 // so we'll do the same in the other direction.
104 if(l->nlist >= (runtime·class_to_allocnpages[sizeclass]<<PageShift)/size ) { 103 if(l->nlist >= (runtime·class_to_allocnpages[sizeclass]<<PageShift)/size ) {
105 runtime·MCentral_FreeList(&runtime·mheap.central[sizeclass], l-> list); 104 runtime·MCentral_FreeList(&runtime·mheap.central[sizeclass], l-> list);
106 l->list = nil; 105 l->list = nil;
107 l->nlist = 0; 106 l->nlist = 0;
108 } 107 }
109 } 108 }
110 109
(...skipping 11 matching lines...) Expand all
122 c->alloc[i] = &emptymspan; 121 c->alloc[i] = &emptymspan;
123 } 122 }
124 l = &c->free[i]; 123 l = &c->free[i];
125 if(l->nlist > 0) { 124 if(l->nlist > 0) {
126 runtime·MCentral_FreeList(&runtime·mheap.central[i], l-> list); 125 runtime·MCentral_FreeList(&runtime·mheap.central[i], l-> list);
127 l->list = nil; 126 l->list = nil;
128 l->nlist = 0; 127 l->nlist = 0;
129 } 128 }
130 } 129 }
131 } 130 }
OLDNEW
« no previous file with comments | « src/pkg/runtime/malloc.goc ('k') | src/pkg/runtime/mgc0.c » ('j') | no next file with comments »

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