mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 16:57:35 +02:00
Initiate major GC after a huge heap allocation
This allows us to reclaim the memory faster and keep memory usage lower.
This commit is contained in:
parent
b76b6974b2
commit
543ce4f4be
2 changed files with 12 additions and 2 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
## TBD
|
## TBD
|
||||||
|
|
||||||
|
Features
|
||||||
|
|
||||||
|
- Initiate major garbage collections faster after allocating a huge object (more than 500K). This allows the system to reclaim the memory faster and keep overall memory usage low for certain workloads.
|
||||||
|
|
||||||
## 0.31.0 - July 27, 2021
|
## 0.31.0 - July 27, 2021
|
||||||
|
|
||||||
|
|
11
gc.c
11
gc.c
|
@ -1447,9 +1447,16 @@ fprintf(stderr, "slowest alloc of %p\n", result);
|
||||||
#endif
|
#endif
|
||||||
if (result) {
|
if (result) {
|
||||||
// We had to allocate memory, start a major collection ASAP!
|
// We had to allocate memory, start a major collection ASAP!
|
||||||
if (heap_type != HEAP_HUGE) {
|
//
|
||||||
|
// Huge heaps are a special case because we always allocate a new page
|
||||||
|
// for them. However, we still initiate a collection for them, giving
|
||||||
|
// us a convenient way to handle short-lived HUGE objects. In practice
|
||||||
|
// this makes a BIG difference in memory usage for the array1 benchmark.
|
||||||
|
// Longer-term there may be a better way to deal with huge objects.
|
||||||
|
//
|
||||||
|
//if (heap_type != HEAP_HUGE) {
|
||||||
gc_start_major_collection(thd);
|
gc_start_major_collection(thd);
|
||||||
}
|
//}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "out of memory error allocating %zu bytes\n", size);
|
fprintf(stderr, "out of memory error allocating %zu bytes\n", size);
|
||||||
fprintf(stderr, "Heap type %d diagnostics:\n", heap_type);
|
fprintf(stderr, "Heap type %d diagnostics:\n", heap_type);
|
||||||
|
|
Loading…
Add table
Reference in a new issue