请教一下
在windows下使用jemalloc,看了下测试例子,是调用je_malloc和je_free操作的
但是项目中已经有了很多malloc和new
必须自己去处理new以及stl::allocator替换成je_malloc么?
还是有类似tcmalloc一样比较方便的使用方法?
黄舟2017-04-17 15:05:28
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?