ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.67k stars 2.98k forks source link

MemoryAPI documentation question #5891

Closed pauluap closed 6 years ago

pauluap commented 6 years ago

Description

Question

I opened a Stackoverflow issue regarding my question - StackOverflow

Basically, it is not completely clear to me whether if the MemoryPool API is usable with non-POD classes that have non-trivial constructors.

Either way, could the documentation be enhanced as to specify what types is usable with the MemoryPool API?

It seems to me that if I want to use a memory pool for nontrivial classes I would need to create one myself or follow one of the other suggestions in the answers/comments to the StackOverflow question.

0xc0170 commented 6 years ago

Either way, could the documentation be enhanced as to specify what types is usable with the MemoryPool API?

I could not locate it neither, we will review it.

It seems to me that if I want to use a memory pool for nontrivial classes I would need to create one myself or follow one of the other suggestions in the answers/comments to the StackOverflow question.

The memory pool API is using memory pool API from RTOS that is in C. The functions you look for if you want to see the implementation are svcRtxMemoryPoolNew and osRtxMemoryPoolAlloc (if pool is alloc is enabled in rtos, it is in our case).

@SenRamakri Please review

SenRamakri commented 6 years ago

The MemoryPool API is purely a pool based memory allocator built on top of CMSIS/RTX Memory Pool implementation(https://www.keil.com/pack/doc/CMSIS/RTOS2/html/group__CMSIS__RTOS__PoolMgmt.html). It does not invoke the object constructor for the objects placed in the pool blocks. The memory pool allocates blocks of memory from the pool and returns the pointer of that block to the user. Its the responsibility of application to initialize the objects placed in memory blocks as required. Hope this clarifies, we will update the documentation on MemoryPool with this info.

0xc0170 commented 6 years ago

https://github.com/ARMmbed/Handbook/pull/388 - should fix this issue

AnotherButler commented 6 years ago

PR #388 has merged, which I believe solves this issue. Please feel free to reopen if you do not feel this has been adequately resolved.