Code Monkey home page Code Monkey logo

memorypool's Introduction

MemoryPool

an implement of a memorypool

一个简单而又强大的内存池实现 1个头文件+1个cpp实现

语法采用c++

#QuickMemoryPool

  • @brief : QuickMemoryPool
  • 一种简单高效的模板定长内存池实现
  • 采用预分配大块内存机制,减少malloc,free等系统call开销
  • 时间复杂度:分配内存O(1),释放内存O(1)
  • 该内存池实现参考Box2D的内存池实现,用模板参数取代了固定长度,并做了一些细节方面的优化
  • 支持任意类型对象(POD,含虚函数的等),支持构造函数,含参构造函数, 自动触发析构函数
  • 为了保持实现的简洁和高效性,该内存池仅仅提供两个接口,申请到的指针需要用户自己做管理
  • 简单测试下,其速度相比不使用内存池的申请释放,速度达到近3倍
  • 内存池结构图 内存池有多个Chunk组成, Chunk0 ,Chunk1, Chunk2,....每个Chunk结构相同

单个Chunk结构由多个block组成,Block里存放着用户数据 Chunk:[Block0,Block1,....

memorypool's People

Contributors

wiltchamberian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.