ljluestc opened a new pull request, #3139:
URL: https://github.com/apache/brpc/pull/3139
### What problem does this PR solve?
- Avoids allocator hangs that may occur after calling the C++ API
`MallocExtension::instance()->ReleaseFreeMemory()` on some tcmalloc
versions/distros.
- Adds automated verification to ensure post-release allocations do not hang.
Issue Number: resolves #200
Problem Summary:
- The weak C++ symbol for `MallocExtension::instance()` may not be reliably
overridden in some environments (e.g., Fedora 26), and calling
`ReleaseFreeMemory()` via that path has been observed to hang subsequent
allocations on tcmalloc 1.7/2.5.
- brpc already uses the stable C API `MallocExtension_ReleaseFreeMemory()`
at runtime; this PR adds tests to prevent regressions and to make verification
straightforward.
### What is changed and the side effects?
Changed:
- Add gtest `test/brpc_tcmalloc_release_unittest.cpp` that:
- Alloc/free memory → call `MallocExtension_ReleaseFreeMemory` (weakly
referenced) → alloc/free again, with a 10s timeout guard to detect hangs.
- Optionally include the standalone smoke test `tcmalloc_release_test.cc`
(uses a weak symbol so it runs with or without libtcmalloc).
Side effects:
- Performance effects:
- None at runtime; this PR is test-only. The existing runtime already
calls the C API and falls back to `malloc_trim` on Linux.
- Breaking backward compatibility:
- None.
---
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]