protomatter: allocator: Never supervisor-alloc while gc available
This may have been contributing to fragmentation of the supervisor heap
This commit is contained in:
parent
23bced26da
commit
0ca270172f
|
@ -2,6 +2,7 @@
|
||||||
#define MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H
|
#define MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "py/gc.h"
|
||||||
#include "py/misc.h"
|
#include "py/misc.h"
|
||||||
#include "supervisor/memory.h"
|
#include "supervisor/memory.h"
|
||||||
|
|
||||||
|
@ -9,11 +10,11 @@
|
||||||
#define _PM_FREE(x) (_PM_free_impl((x)), (x)=NULL, (void)0)
|
#define _PM_FREE(x) (_PM_free_impl((x)), (x)=NULL, (void)0)
|
||||||
|
|
||||||
static inline void *_PM_allocator_impl(size_t sz) {
|
static inline void *_PM_allocator_impl(size_t sz) {
|
||||||
supervisor_allocation *allocation = allocate_memory(align32_size(sz), true);
|
if (gc_alloc_possible()) {
|
||||||
if (allocation) {
|
|
||||||
return allocation->ptr;
|
|
||||||
} else {
|
|
||||||
return m_malloc(sz + sizeof(void*), true);
|
return m_malloc(sz + sizeof(void*), true);
|
||||||
|
} else {
|
||||||
|
supervisor_allocation *allocation = allocate_memory(align32_size(sz), true);
|
||||||
|
return allocation ? allocation->ptr : NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue