mirror of
https://github.com/janet-lang/janet
synced 2025-11-13 13:57:19 +00:00
Keep count fo allocated memory via malloc.
We normally only track memory allocated with janet_gcalloc, but if only a few very large normal memory blocks are allocated, the GC will never run. Se simply need to increment a count when we allocate memory so that the next time we enter the VM, we will be able to run a collection if needed.
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include <math.h>
|
||||
#include <janet.h>
|
||||
#include "util.h"
|
||||
#include "state.h"
|
||||
#endif
|
||||
|
||||
/* Macro fills */
|
||||
@@ -161,6 +162,7 @@ Janet(janet_wrap_number)(double x) {
|
||||
void *janet_memalloc_empty(int32_t count) {
|
||||
int32_t i;
|
||||
void *mem = malloc(count * sizeof(JanetKV));
|
||||
janet_vm_next_collection += count * sizeof(JanetKV);
|
||||
if (NULL == mem) {
|
||||
JANET_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user