Hi, I would like to pre-allocate separate heap space (outside of main heap) and be able to use the returned memory for my application's memory needs (just like malloc()). It seems we can have up to 256 heaps. Have few questions around this:
1) My understanding is that currently the main heap is allocated using clib_mem_init()/clib_mem_init_thread_safe() and the subsequent calls like clib_mem_alloc(size) will carve out memory from within the main heap and returned to clients (similar to glibc malloc()). Is this correct? If so, I would like to know how this is achieved since I don't see the returned pointer from clib_mem_init()/clib_mem_init_thread_safe() is being referenced or used anywhere. 2) Some applications are using mheap_alloc() directly to create new heap. Ex: void *heap; void *oldheap; heap = mheap_alloc (0, 10<<20); oldheap = clib_mem_set_heap (heap); .. .. clib_mem_set_heap (oldheap); << why is this required to write back oldheap into per-cpu heap? What I really like to know is once the heap is allocated how can we use it? Does it imply to have pools/hashes to be created to be able to use it? I'm expecting something which takes void *heap (created using mheap_alloc) and returns the requested memory for a given size from within the heap so that we don't need to use pools/hashes. Ex: void *foobar(void *mheap, size_t size); Is it possible? Thanks, Harish
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#11503): https://lists.fd.io/g/vpp-dev/message/11503 Mute This Topic: https://lists.fd.io/mt/28617718/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-