Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Unified Diff: runtime/vm/malloc_hooks.cc

Issue 2748403002: Added page to Observatory to display native memory allocation information. (Closed)
Patch Set: Added tests to verify sample tries inclusive/exclusive allocations. Element now displays memory con… Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/malloc_hooks.cc
diff --git a/runtime/vm/malloc_hooks.cc b/runtime/vm/malloc_hooks.cc
index d838457889c2eb61561053c0ef251d79534492cb..09b758982c34a0e2fe3d9a1d683b4400673e785f 100644
--- a/runtime/vm/malloc_hooks.cc
+++ b/runtime/vm/malloc_hooks.cc
@@ -131,21 +131,35 @@ class MallocLocker : public ValueObject {
// -Stack trace corresponding to the location of allocation, if applicable
class AllocationInfo {
public:
- explicit AllocationInfo(intptr_t allocation_size)
- : sample_(NULL), allocation_size_(allocation_size) {
+ explicit AllocationInfo(uword address, intptr_t allocation_size)
zra 2017/03/16 20:36:37 Don't need 'explicit' when there is more than one
bkonyi 2017/03/21 01:53:23 Done.
+ : sample_(NULL), address_(address), allocation_size_(allocation_size) {
// Stack trace collection is disabled when we are in the process of creating
// the first OSThread in order to prevent deadlocks.
if (MallocHooksState::ProfilingEnabled() &&
MallocHooksState::stack_trace_collection_enabled()) {
- sample_ = Profiler::SampleNativeAllocation(kSkipCount);
+ sample_ = Profiler::SampleNativeAllocation(kSkipCount, address,
+ allocation_size);
+ ASSERT(sample_->native_allocation_address() == address_);
}
}
+ ~AllocationInfo() {
+ if (sample_ == NULL) {
+ return;
+ }
+ uword allocation_address = sample_->native_allocation_address();
+ if (allocation_address != address_) {
zra 2017/03/16 20:36:37 Why might this happen?
bkonyi 2017/03/16 20:48:40 The samples are stored in a ring buffer and are ev
bkonyi 2017/03/21 01:53:23 I've changed how this is done so that we should be
+ return;
+ }
+ sample_->set_native_allocation_address(0);
Cutch 2017/03/16 20:38:16 what about the size too?
bkonyi 2017/03/21 01:53:23 I've changed how I check if a native allocation sa
+ }
+
Sample* sample() const { return sample_; }
intptr_t allocation_size() const { return allocation_size_; }
private:
Sample* sample_;
zra 2017/03/16 20:36:37 It might be worthwhile to make an explicit note he
bkonyi 2017/03/21 01:53:23 Done.
+ uword address_;
intptr_t allocation_size_;
// The number of frames that are generated by the malloc hooks and collection
@@ -154,7 +168,7 @@ class AllocationInfo {
// malloc_hook_tests.cc might fail, particularily
// StackTraceMallocHookLengthTest. If this value is updated, please make sure
// that the MallocHooks test cases pass on all platforms.
- static const intptr_t kSkipCount = 5;
+ static const intptr_t kSkipCount = 6;
};
@@ -416,7 +430,8 @@ void MallocHooksState::RecordAllocHook(const void* ptr, size_t size) {
// Now that we hold the lock, check to make sure everything is still active.
if ((ptr != NULL) && MallocHooksState::Active()) {
MallocHooksState::IncrementHeapAllocatedMemoryInBytes(size);
- MallocHooksState::address_map()->Insert(ptr, new AllocationInfo(size));
+ MallocHooksState::address_map()->Insert(
+ ptr, new AllocationInfo(reinterpret_cast<uword>(ptr), size));
}
}

Powered by Google App Engine
This is Rietveld 408576698