c++ - jemalloc 怎么自动替换掉项目中已使用的malloc和new?
伊谢尔伦
伊谢尔伦 2017-04-17 15:03:28
0
1
2503

请教一下
在windows下使用jemalloc,看了下测试例子,是调用je_mallocje_free操作的
但是项目中已经有了很多malloc和new

必须自己去处理new以及stl::allocator替换成je_malloc么?
还是有类似tcmalloc一样比较方便的使用方法?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
黄舟

I don’t know how you use it under Windows, and I’m not familiar with VS, but the principle should apply.
If you still use gcc/mingw, you can directly link the jemalloc library first and then globally replace it with the implementation using jemalloc.
Here is an example:
cc ​​app.c -o app -L${JEMALLOC_PATH}/lib -Wl,-rpath,${JEMALLOC_PATH}/lib -ljemalloc
From the documentation:
https ://github.com/jemalloc/j...
In Linux, you can also directly add the compiled jemalloc library path to LD_LIBRARY_PATH

This is a common use of dependency injection during connection.
You can try to answer where the original malloc function came from, and how is it connected to the current program?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template