Added implementations for cvSetMemoryManager and some related APIs (Feature #3074)

Added by Daniil Osokin about 4 years ago. Updated about 2 years ago.

Status:Cancelled Start date:2013-06-06
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:


Target version:Next Hackathon
Difficulty: Pull request:


From the original pull request (

1. Provide the implementation for cvSetMemoryManager(). cvRemoveMemoryManager() is also added but it just simply switches the memory manager to the default allocator/deallocator, i.e. system malloc/free. Currently the code limits the number of user-defined memory managers to 1022.
2. Allow users to activate memory pool at runtime. Currently in opencv, if we want to activate the memory pool, we need to remove "#define CV_USE_SYSTEM_MALLOC" in alloc.c and then recompile opencv. In this patch, we can activate the memory tool by involving cvTurnOnMemoryPool(). Also we can turn off it via cvTurnOffMemoryPool(). When calling cvTurnOnMemoryPool(), users can specific the block size used in the memory pool (if an object's size is larger than block size, it will be allocated by system malloc/free).
However currently it doesn't allow to change the block size. That is to say, if the memory pool is turned on, it can only be re-turned on with the same block size.
3. The code doesn't allow user to apply different memory manager to different threads. If this feature is needed, we may need to change lots of code in opencv's basic structure and may result in lots of problems.


Updated by Philip L about 2 years ago

already closed PR if needed please reopen such a PR with updated code

  • Status changed from Open to Done
  • % Done changed from 0 to 100

Updated by Philip L about 2 years ago

  • Status changed from Done to Cancelled
  • % Done changed from 100 to 0

Also available in: Atom PDF