Commit 82459763 authored by Marius Wachtler's avatar Marius Wachtler

gc realloc: subtract freed bytes from bytesAllocatedSinceCollection

parent 9cda8dda
...@@ -357,6 +357,8 @@ GCAllocation* SmallArena::realloc(GCAllocation* al, size_t bytes) { ...@@ -357,6 +357,8 @@ GCAllocation* SmallArena::realloc(GCAllocation* al, size_t bytes) {
#else #else
memcpy(rtn, al, std::min(bytes, size)); memcpy(rtn, al, std::min(bytes, size));
#endif #endif
if (bytesAllocatedSinceCollection > size)
bytesAllocatedSinceCollection -= size;
free(al); free(al);
return rtn; return rtn;
...@@ -772,6 +774,9 @@ GCAllocation* LargeArena::realloc(GCAllocation* al, size_t bytes) { ...@@ -772,6 +774,9 @@ GCAllocation* LargeArena::realloc(GCAllocation* al, size_t bytes) {
GCAllocation* rtn = heap->alloc(bytes); GCAllocation* rtn = heap->alloc(bytes);
memcpy(rtn, al, std::min(bytes, obj->size)); memcpy(rtn, al, std::min(bytes, obj->size));
if (bytesAllocatedSinceCollection > size)
bytesAllocatedSinceCollection -= size;
_freeLargeObj(obj); _freeLargeObj(obj);
return rtn; return rtn;
} }
...@@ -994,6 +999,9 @@ GCAllocation* HugeArena::realloc(GCAllocation* al, size_t bytes) { ...@@ -994,6 +999,9 @@ GCAllocation* HugeArena::realloc(GCAllocation* al, size_t bytes) {
GCAllocation* rtn = heap->alloc(bytes); GCAllocation* rtn = heap->alloc(bytes);
memcpy(rtn, al, std::min(bytes, obj->size)); memcpy(rtn, al, std::min(bytes, obj->size));
if (bytesAllocatedSinceCollection > obj->size)
bytesAllocatedSinceCollection -= obj->size;
_freeHugeObj(obj); _freeHugeObj(obj);
return rtn; return rtn;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment