Coder Social home page Coder Social logo

ftmalloc's Introduction

ftmalloc

fast malloc. similar to google-tcmalloc.

因为项目需要管理大块的共享内存,之前的方案采用的线性管理方式,内存分配、释放,以及内存碎片的处理都有非常大的局限性,不仅处理速度慢,而且性能不稳定。所以提出优化需求。
因为tcmalloc是进程内存管理,没法直接移植到管理共享内存上,所以需要重新开发。本工程就是针对项目做得工作,后面通过抽取内存管理和分配部分的逻辑,修改成针对进程内存管理,形成本仓库,并参考tcmalloc,提供malloc/free/new/delete等接口,提供和tcmalloc类似的内存库功能。


###设计思路
####freelist和切片规则和tcmalloc一致,这部分没有过多设计,哈希链表管理线程内存切片
####使用红黑树实现页和切片的映射关系
####使用红黑树实现页管理关系
####模仿linux内核的slab实现从系统内存分配内存




###使用
####在ftmalloc目录下执行make,会将src目录下的代码编译,生成libftmalloc.so.
####test目录下会编译main.cpp生成test程序
####LD_PRELOAD=../src/libftmalloc.so ./test 指定使用libtcmalloc.so作为程序的内存库,申请和释放内存都会通过libftmalloc.so完成。

ftmalloc's People

Contributors

sudokuhk avatar

Stargazers

 avatar  avatar akin avatar  avatar  avatar Daves_Hou avatar  avatar  avatar  avatar olly avatar EricZheng avatar che j avatar tashanzhishi avatar  avatar Zhang Hongtao avatar Natsu avatar chu avatar Weixing Sun avatar Bao Hexing avatar bxfula avatar  avatar

Watchers

James Cloos avatar  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.