OLD | NEW |
1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 // a byte sequence in memory that matches an address of | 1417 // a byte sequence in memory that matches an address of |
1418 // a heap object which is in fact leaked. | 1418 // a heap object which is in fact leaked. |
1419 // I.e. in very rare and probably not repeatable/lasting cases | 1419 // I.e. in very rare and probably not repeatable/lasting cases |
1420 // we might miss some real heap memory leaks. | 1420 // we might miss some real heap memory leaks. |
1421 RAW_VLOG(14, "Found pointer to %p of %"PRIuS" bytes at %p " | 1421 RAW_VLOG(14, "Found pointer to %p of %"PRIuS" bytes at %p " |
1422 "inside %p of size %"PRIuS"", | 1422 "inside %p of size %"PRIuS"", |
1423 ptr, object_size, object, whole_object, whole_size); | 1423 ptr, object_size, object, whole_object, whole_size); |
1424 if (VLOG_IS_ON(15)) { | 1424 if (VLOG_IS_ON(15)) { |
1425 // log call stacks to help debug how come something is not a leak | 1425 // log call stacks to help debug how come something is not a leak |
1426 HeapProfileTable::AllocInfo alloc; | 1426 HeapProfileTable::AllocInfo alloc; |
1427 if (!heap_profile->FindAllocDetails(ptr, &alloc)) { | 1427 bool r = heap_profile->FindAllocDetails(ptr, &alloc); |
1428 RAW_LOG(FATAL, "FindAllocDetails failed on ptr %p", ptr); | 1428 r = r; // suppress compiler warning in non-debug mode |
1429 } | 1429 RAW_DCHECK(r, ""); // sanity |
1430 RAW_LOG(INFO, "New live %p object's alloc stack:", ptr); | 1430 RAW_LOG(INFO, "New live %p object's alloc stack:", ptr); |
1431 for (int i = 0; i < alloc.stack_depth; ++i) { | 1431 for (int i = 0; i < alloc.stack_depth; ++i) { |
1432 RAW_LOG(INFO, " @ %p", alloc.call_stack[i]); | 1432 RAW_LOG(INFO, " @ %p", alloc.call_stack[i]); |
1433 } | 1433 } |
1434 } | 1434 } |
1435 live_object_count += 1; | 1435 live_object_count += 1; |
1436 live_byte_count += object_size; | 1436 live_byte_count += object_size; |
1437 live_objects->push_back(AllocObject(ptr, object_size, | 1437 live_objects->push_back(AllocObject(ptr, object_size, |
1438 IGNORED_ON_HEAP)); | 1438 IGNORED_ON_HEAP)); |
1439 } | 1439 } |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2289 // static | 2289 // static |
2290 const void* HeapLeakChecker::GetAllocCaller(void* ptr) { | 2290 const void* HeapLeakChecker::GetAllocCaller(void* ptr) { |
2291 // this is used only in the unittest, so the heavy checks are fine | 2291 // this is used only in the unittest, so the heavy checks are fine |
2292 HeapProfileTable::AllocInfo info; | 2292 HeapProfileTable::AllocInfo info; |
2293 { SpinLockHolder l(&heap_checker_lock); | 2293 { SpinLockHolder l(&heap_checker_lock); |
2294 RAW_CHECK(heap_profile->FindAllocDetails(ptr, &info), ""); | 2294 RAW_CHECK(heap_profile->FindAllocDetails(ptr, &info), ""); |
2295 } | 2295 } |
2296 RAW_CHECK(info.stack_depth >= 1, ""); | 2296 RAW_CHECK(info.stack_depth >= 1, ""); |
2297 return info.call_stack[0]; | 2297 return info.call_stack[0]; |
2298 } | 2298 } |
OLD | NEW |