Giter Site home page Giter Site logo

memorypool's Introduction

扩大福内存池

姑且命名为扩大福内存池
扩大福内存池是一个轻量级且比较高效的定长内存池
只有3个头文件, 把头文件带到你的项目中引用就可以使用
其中一个头文件为分配器对象
一个为定长内存池对象
一个为变长内存池对象

扩大福内存池仅使用几个基础API来支持这些功能
定长内存池提供以下方法
对应的文件 CMemoryObjectPool.h

  • Release 释放内存池
  • clear 清空已分配内存, 不释放内存
  • init 初始化内存池
  • malloc 分配一个成员, 分配失败抛出 std::bad_alloc() 异常
  • malloc_arr 分配一个数组, 分配失败抛出 std::bad_alloc() 异常
  • realloc_arr 重定义数组成员数, 传递是地址不是内存池分配出去的地址抛出 std::exception() 异常
  • free_arr 释放数组, 传递是地址不是内存池分配出去的地址抛出 std::exception() 异常
  • free 释放一个成员, 传递是地址不是内存池分配出去的地址抛出 std::exception() 异常
  • query 查询指定地址是否是内存池里分配出去的地址
  • dump 输出当前内存池状态

变长内存池对应的文件 CMemoryPool.h 目前暂未实现

分配器对应文件 CMemoryAllocator.h 目前暂未使用, 想法是分配可执行属性的内存来使用
或者就让用户自行实现分配器, 或者就使用默认的

想实现暂未实现的功能

  • 支持线程安全
  • 作用域, 一个开始一个结束作用域的方法, 退出作用域后就回收作用域内分配的内存
  • debug模式下检测越界之类的
  • 其他等补充

作者

扩大福内存池目前由扩大福设计和实现, 希望有更多志同道合的朋友加入

开源协议

本代码使用MIT开源协议

  • 允许任何人以任何方式使用
  • 需署名作者
  • 作者不承担代码使用后的任何风险

memorypool's People

Contributors

zjljaycn 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.