-
Notifications
You must be signed in to change notification settings - Fork 5.5k
debug: Link in the debug version of tcmalloc for debug builds. #5424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1ed5aba
debug: Link in the debug version of tcmalloc for debug builds.
jmarantz 49f610c
Merge branch 'master' into debug-malloc
jmarantz 93d0bc3
Merge branch 'master' into debug-malloc
jmarantz 1aa4196
revive tcmalloc-debug approach, requiring more explicit config.
jmarantz 8ff4d3a
Merge branch 'master' into debug-malloc
jmarantz dd61c91
Remove superflous define.
jmarantz 301ce01
Fix #define name to disable profiling.
jmarantz c7cd6a1
Fix another stray old #define.
jmarantz 632652c
Add dubious but -- at this point -- functional test for ScribbleOnDel…
jmarantz d882947
Add memory-debugging to the compile-time options.
jmarantz c6e72e3
include profiler.h to get the ifdef.
jmarantz 98e7d95
Add comment explaining profiling dependency and #define.
jmarantz ee8af23
Convert debug_memory=enable to tcmalloc=debug, etc.
jmarantz ae5b1ec
Merge branch 'master' into debug-malloc
jmarantz b5982e6
Document the tcmalloc bazel command options.
jmarantz f6eacf0
Added tcmalloc=disabled to the disabling section.
jmarantz 80cb279
Remove tcmalloc=disabled from enabling section.
jmarantz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| licenses(["notice"]) # Apache 2 | ||
|
|
||
| load( | ||
| "//bazel:envoy_build_system.bzl", | ||
| "envoy_cc_test", | ||
| "envoy_package", | ||
| ) | ||
|
|
||
| envoy_package() | ||
|
|
||
| envoy_cc_test( | ||
| name = "debug_test", | ||
| srcs = ["debug_test.cc"], | ||
| deps = ["//source/common/memory:stats_lib"], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #include "common/memory/stats.h" | ||
|
|
||
| #include "gtest/gtest.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Memory { | ||
|
|
||
| #ifdef ENVOY_MEMORY_DEBUG_ENABLED | ||
|
|
||
| constexpr int ArraySize = 10; | ||
|
|
||
| struct MyStruct { | ||
| MyStruct() : x_(0) {} // words_ is uninitialized; will have whatever allocator left there. | ||
| uint64_t x_; | ||
| uint64_t words_[ArraySize]; | ||
| }; | ||
|
|
||
| TEST(MemoryDebug, ByteSize) { | ||
| uint64_t before = Stats::totalCurrentlyAllocated(); | ||
| auto ptr = std::make_unique<MyStruct>(); | ||
| uint64_t after = Stats::totalCurrentlyAllocated(); | ||
| EXPECT_LE(sizeof(MyStruct), after - before); | ||
| } | ||
|
|
||
| TEST(MemoryDebug, ScribbleOnNew) { | ||
| auto ptr = std::make_unique<MyStruct>(); | ||
| for (int i = 0; i < ArraySize; ++i) { | ||
| // This is the pattern written by tcmalloc's debug library. | ||
| EXPECT_EQ(0xabababababababab, ptr->words_[i]); | ||
| } | ||
| } | ||
|
jmarantz marked this conversation as resolved.
|
||
|
|
||
| TEST(MemoryDebug, ZeroByteAlloc) { auto ptr = std::make_unique<uint8_t[]>(0); } | ||
|
|
||
| #endif // ENVOY_MEMORY_DEBUG_ENABLED | ||
|
|
||
| } // namespace Memory | ||
| } // namespace Envoy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.