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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 return true; | 519 return true; |
520 } else { | 520 } else { |
521 RAW_LOG(ERROR, "Failed dumping filtered heap profile to %s", file_name); | 521 RAW_LOG(ERROR, "Failed dumping filtered heap profile to %s", file_name); |
522 return false; | 522 return false; |
523 } | 523 } |
524 } | 524 } |
525 | 525 |
526 void HeapProfileTable::CleanupOldProfiles(const char* prefix) { | 526 void HeapProfileTable::CleanupOldProfiles(const char* prefix) { |
527 if (!FLAGS_cleanup_old_heap_profiles) | 527 if (!FLAGS_cleanup_old_heap_profiles) |
528 return; | 528 return; |
529 string pattern = string(prefix) + ".*" + kFileExt; | 529 char buf[1000]; |
| 530 snprintf(buf, 1000,"%s.%05d.", prefix, getpid()); |
| 531 string pattern = string(buf) + ".*" + kFileExt; |
| 532 |
530 #if defined(HAVE_GLOB_H) | 533 #if defined(HAVE_GLOB_H) |
531 glob_t g; | 534 glob_t g; |
532 const int r = glob(pattern.c_str(), GLOB_ERR, NULL, &g); | 535 const int r = glob(pattern.c_str(), GLOB_ERR, NULL, &g); |
533 if (r == 0 || r == GLOB_NOMATCH) { | 536 if (r == 0 || r == GLOB_NOMATCH) { |
534 const int prefix_length = strlen(prefix); | 537 const int prefix_length = strlen(prefix); |
535 for (int i = 0; i < g.gl_pathc; i++) { | 538 for (int i = 0; i < g.gl_pathc; i++) { |
536 const char* fname = g.gl_pathv[i]; | 539 const char* fname = g.gl_pathv[i]; |
537 if ((strlen(fname) >= prefix_length) && | 540 if ((strlen(fname) >= prefix_length) && |
538 (memcmp(fname, prefix, prefix_length) == 0)) { | 541 (memcmp(fname, prefix, prefix_length) == 0)) { |
539 RAW_VLOG(1, "Removing old heap profile %s", fname); | 542 RAW_VLOG(1, "Removing old heap profile %s", fname); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 char* unused) { | 690 char* unused) { |
688 // Perhaps also log the allocation stack trace (unsymbolized) | 691 // Perhaps also log the allocation stack trace (unsymbolized) |
689 // on this line in case somebody finds it useful. | 692 // on this line in case somebody finds it useful. |
690 RAW_LOG(ERROR, "leaked %"PRIuS" byte object %p", v->bytes, ptr); | 693 RAW_LOG(ERROR, "leaked %"PRIuS" byte object %p", v->bytes, ptr); |
691 } | 694 } |
692 | 695 |
693 void HeapProfileTable::Snapshot::ReportIndividualObjects() { | 696 void HeapProfileTable::Snapshot::ReportIndividualObjects() { |
694 char unused; | 697 char unused; |
695 map_.Iterate(ReportObject, &unused); | 698 map_.Iterate(ReportObject, &unused); |
696 } | 699 } |
OLD | NEW |