Move every alloc over 256 bytes into PSRAM
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ CONFIG_ESP32_REV_MIN_3=y
|
|||||||
CONFIG_ESP_PHY_REDUCE_TX_POWER=y
|
CONFIG_ESP_PHY_REDUCE_TX_POWER=y
|
||||||
CONFIG_PM_ENABLE=y
|
CONFIG_PM_ENABLE=y
|
||||||
CONFIG_SPIRAM=y
|
CONFIG_SPIRAM=y
|
||||||
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192
|
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=256
|
||||||
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
|
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
|
||||||
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
|
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
|
||||||
CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y
|
CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY=y
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-only
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
idf_component_register(
|
idf_component_register(
|
||||||
SRCS "memory_resource.cpp" "allocator.cpp"
|
SRCS "memory_resource.cpp"
|
||||||
INCLUDE_DIRS "include"
|
INCLUDE_DIRS "include"
|
||||||
REQUIRES "esp_psram")
|
REQUIRES "esp_psram")
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS})
|
target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS})
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2023 jacqueline <me@jacqueline.id.au>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include "esp_heap_caps.h"
|
|
||||||
|
|
||||||
void* operator new[](std::size_t sz) {
|
|
||||||
if (sz == 0) {
|
|
||||||
++sz; // avoid std::malloc(0) which may return nullptr on success
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sz > 512) {
|
|
||||||
return heap_caps_malloc(sz, MALLOC_CAP_SPIRAM);
|
|
||||||
}
|
|
||||||
|
|
||||||
return heap_caps_malloc(sz, MALLOC_CAP_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete[](void* ptr) noexcept {
|
|
||||||
heap_caps_free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator delete[](void* ptr, std::size_t size) noexcept {
|
|
||||||
heap_caps_free(ptr);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user