@liw Iāve tried this for out of memory conditions (aka memory exhaustion) in Rust but thereās no -ENOMEM
:-) In unstable
there is handle_alloc_error()
but it is. sort of complicated track to adapt. Would be nice if you could do this every and each at the site, as callback indirection sucksā¦
In this thread I see one common and wrong conclusion:
āYeah, but there are also other application areas, such as embedded environments with less RAM and no memory overcomittment.ā
For restricted embedded payloads and stuff like that you usually define metrics already at the compile time, and use crates such as heapless. It is exactly dynamic over-committed memory where it would be nice to explicitly deal with this unexpected corner case.
It is pretty hard to sometimes discuss about memory issues in Rust with ārustaceansā because they are living in the myth of Rust being memory-safe. Nothing is never fully memory-safe.
@liw Iāve tried this for out of memory conditions (aka memory exhaustion) in Rust but thereās no -ENOMEM
:-) In unstable
there is handle_alloc_error()
but it is. sort of complicated track to adapt. Would be nice if you could do this every and each at the site, as callback indirection sucksā¦
In this thread I see one common and wrong conclusion:
āYeah, but there are also other application areas, such as embedded environments with less RAM and no memory overcomittment.ā
For restricted embedded payloads and stuff like that you usually define metrics already at the compile time, and use crates such as heapless. It is exactly dynamic over-committed memory where it would be nice to explicitly deal with this unexpected corner case.
It is pretty hard to sometimes discuss about memory issues in Rust with ārustaceansā because they are living in the myth of Rust being memory-safe. Nothing is never fully memory-safe.
@jmorris given that this is possible i would give it a shot in the similar situation. thereās lot of nostd stuff that you can probably easily adapt to this framework like my go-to rust library heapless.
iāve taken practice even in non-embedded (user space) rust that i prefer nostd and heapless structures to the max over features when picking dependencies for a rust program. sort of addition of minimizing the number of unsafe regions is to minimize the number of heapful regions.
macro(import_binary_as_elf Path Symbol Target)
set(objcopy_flags -I binary -O default -B riscv)
string(MAKE_C_IDENTIFIER ${Path} unstripped)
add_custom_command(
OUTPUT ${Path}.elf
DEPENDS ${Target}
COMMAND
${CMAKE_OBJCOPY} ${objcopy_flags}
${Path} ${Path}.elf
COMMAND
${CMAKE_OBJCOPY} -N
_binary_${unstripped}_end ${Path}.elf
COMMAND
${CMAKE_OBJCOPY} --redefine-sym
_binary_${unstripped}_start=${Symbol}_start
${Path}.elf
COMMAND
${CMAKE_OBJCOPY} --redefine-sym
_binary_${unstripped}_size=${Symbol}_size
${Path}.elf
)
add_custom_target(${Symbol}_elf DEPENDS ${Path}.elf)
endmacro()