Skip to content

MemoryPool

developer-kikikaikai edited this page Jul 21, 2018 · 8 revisions

Here, only show simply explain what is it. Base of this page is How to use library? and When it can help you?.

And this library contains my preference, and maybe custom pattern for my preference a little.

What is MemoryPool?

Simply definition in here:

  • By using this, user can get allocated memory smoothly. This allocated memory is managed in this.
  • It can use like a prototype to use constructor.

How to show by C?

Store list of allocated data, which size modify modified to 2^x bit size. like following:

init.png

And memory instances update by using input constructor if you want.

When get memory:

get.png

When release memory:

relrease.png

design

Class

Only MemoryPool class which has allocated memory list as above.

API Definition

Please see Doxygen. Raw code is here

How to use:

  1. to call mpool_create, Create MemoryPool instance (has list of allocate memory pointer initialize by constructor)
  2. mpool_get to get allocated memory.
  3. mpool_release to release allocated memory (this means not free, only unset used flag)
  4. If you want to do all used memory loop, please use FOR_ALL_USEDMEM macro.

sample

Please see test code.

Operating environment

Support Linux

I check:

  • Ubuntu(18.04 Desktop)
  • Cent OS(7.5.1804)

Supported libraries pattern

Supported libraries of famous design

Only sample pattern

Now I don't write wiki, only add link of Japanese website Qiita.

  • Abstract Factory
  • Factory Method
  • Adapter
  • Bridge
  • Decorator
  • Facade
  • Proxy
  • Command
  • Mediator
  • Strategy
  • Template Method
  • Visitor

No create sample

  • Composite
  • Interpreter
  • Iterator

Reference (base of this package)

On Japanese website Qiita

Clone this wiki locally