Shanks0224 opened a new pull request, #18077:
URL: https://github.com/apache/nuttx/pull/18077
## Summary
The simulation platform previously used a custom heap implementation that
lacked support for standard memory management features. This prevented
the use of shared memory mechanisms and consistent heap
debugging across platforms.
This patch migrates arch/sim to use the standard umm_heap framework while
maintaining necessary platform-specific customizations. The changes enable:
1. Standard heap management with shared memory support
2. Accurate memory statistics through timely delayed free processing
3. Extensible procfs interface for memory debugging
4. Proper accounting of heap metadata
Similar implementations exist in other platforms which use the umm_heap
framework
with platform-specific hooks.
## Impact
- **Users**: Enables shared memory features (OpenAMP) on simulation platform
- **Build**: No impact on build process; changes are conditional
- **Compatibility**: Maintains backward compatibility with existing sim code
- **Security**: No security impact; heap management internal to kernel
## Testing
**Host**: Ubuntu 22.04 x86_64
**Toolchain**: gcc 11.4.0
**Configuration**: sim:nsh with `MM_UMM_CUSTOMIZE_MANAGER` enabled
### Custom application testing
Created a test application (`hello`) to verify heap functionality:
#### Source Code
```c
/****************************************************************************
* apps/examples/hello/hello_main.c
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, FAR char *argv[])
{
printf("Hello, World!!!\n");
char *p = (char *)malloc(100);
p[50] = 'a';
printf("p[50] = %c\n", p[50]);
printf("p = %p\n", p);
free(p);
return 0;
}
```
#### Build and Run
```bash
cmake -B build_sim -DBOARD_CONFIG=boards/sim/sim/sim/configs/nsh -GNinja
cmake --build build_sim
gdb-multiarch build_sim/nuttx
```
#### Output
```text
nsh> hello
Hello, World!!!
p[50] = a
p = 0x401bcdf0
nsh>
```
#### Results
✅ malloc(100) returns valid pointer 0x401bcdf0
✅ Memory write p[50] = 'a' succeeds
✅ Memory read outputs correct value a
✅ free(p) executes without crash
✅ Application exits cleanly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]