OLD | NEW |
1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 return true; | 424 return true; |
425 } else { | 425 } else { |
426 RAW_LOG(ERROR, "Failed dumping filtered heap profile to %s", file_name); | 426 RAW_LOG(ERROR, "Failed dumping filtered heap profile to %s", file_name); |
427 return false; | 427 return false; |
428 } | 428 } |
429 } | 429 } |
430 | 430 |
431 void HeapProfileTable::CleanupOldProfiles(const char* prefix) { | 431 void HeapProfileTable::CleanupOldProfiles(const char* prefix) { |
432 if (!FLAGS_cleanup_old_heap_profiles) | 432 if (!FLAGS_cleanup_old_heap_profiles) |
433 return; | 433 return; |
434 string pattern = string(prefix) + ".*" + kFileExt; | 434 char buf[1000]; |
| 435 snprintf(buf, 1000,"%s.%05d.", prefix, getpid()); |
| 436 string pattern = string(buf) + ".*" + kFileExt; |
| 437 |
435 #if defined(HAVE_GLOB_H) | 438 #if defined(HAVE_GLOB_H) |
436 glob_t g; | 439 glob_t g; |
437 const int r = glob(pattern.c_str(), GLOB_ERR, NULL, &g); | 440 const int r = glob(pattern.c_str(), GLOB_ERR, NULL, &g); |
438 if (r == 0 || r == GLOB_NOMATCH) { | 441 if (r == 0 || r == GLOB_NOMATCH) { |
439 const int prefix_length = strlen(prefix); | 442 const int prefix_length = strlen(prefix); |
440 for (int i = 0; i < g.gl_pathc; i++) { | 443 for (int i = 0; i < g.gl_pathc; i++) { |
441 const char* fname = g.gl_pathv[i]; | 444 const char* fname = g.gl_pathv[i]; |
442 if ((strlen(fname) >= prefix_length) && | 445 if ((strlen(fname) >= prefix_length) && |
443 (memcmp(fname, prefix, prefix_length) == 0)) { | 446 (memcmp(fname, prefix, prefix_length) == 0)) { |
444 RAW_VLOG(1, "Removing old heap profile %s", fname); | 447 RAW_VLOG(1, "Removing old heap profile %s", fname); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 char* unused) { | 595 char* unused) { |
593 // Perhaps also log the allocation stack trace (unsymbolized) | 596 // Perhaps also log the allocation stack trace (unsymbolized) |
594 // on this line in case somebody finds it useful. | 597 // on this line in case somebody finds it useful. |
595 RAW_LOG(ERROR, "leaked %"PRIuS" byte object %p", v->bytes, ptr); | 598 RAW_LOG(ERROR, "leaked %"PRIuS" byte object %p", v->bytes, ptr); |
596 } | 599 } |
597 | 600 |
598 void HeapProfileTable::Snapshot::ReportIndividualObjects() { | 601 void HeapProfileTable::Snapshot::ReportIndividualObjects() { |
599 char unused; | 602 char unused; |
600 map_.Iterate(ReportObject, &unused); | 603 map_.Iterate(ReportObject, &unused); |
601 } | 604 } |
OLD | NEW |