| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 #include "config_for_unittests.h" | 39 #include "config_for_unittests.h" |
| 40 #include <stdio.h> | 40 #include <stdio.h> |
| 41 #include <stdlib.h> | 41 #include <stdlib.h> |
| 42 #include <string> | 42 #include <string> |
| 43 #include "base/logging.h" | 43 #include "base/logging.h" |
| 44 #include <google/malloc_extension.h> | 44 #include <google/malloc_extension.h> |
| 45 | 45 |
| 46 using std::string; | 46 using std::string; |
| 47 | 47 |
| 48 extern "C" void* AllocateAllocate() ATTRIBUTE_NOINLINE; |
| 49 |
| 48 extern "C" void* AllocateAllocate() { | 50 extern "C" void* AllocateAllocate() { |
| 49 // The VLOG's are mostly to discourage inlining | 51 // The VLOG's are mostly to discourage inlining |
| 50 VLOG(1, "Allocating some more"); | 52 VLOG(1, "Allocating some more"); |
| 51 void* p = malloc(10000); | 53 void* p = malloc(10000); |
| 52 VLOG(1, "Done allocating"); | 54 VLOG(1, "Done allocating"); |
| 53 return p; | 55 return p; |
| 54 } | 56 } |
| 55 | 57 |
| 56 static void WriteStringToFile(const string& s, const string& filename) { | 58 static void WriteStringToFile(const string& s, const string& filename) { |
| 57 FILE* fp = fopen(filename.c_str(), "w"); | 59 FILE* fp = fopen(filename.c_str(), "w"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 string s; | 73 string s; |
| 72 MallocExtension::instance()->GetHeapSample(&s); | 74 MallocExtension::instance()->GetHeapSample(&s); |
| 73 WriteStringToFile(s, string(argv[1]) + ".heap"); | 75 WriteStringToFile(s, string(argv[1]) + ".heap"); |
| 74 | 76 |
| 75 s.clear(); | 77 s.clear(); |
| 76 MallocExtension::instance()->GetHeapGrowthStacks(&s); | 78 MallocExtension::instance()->GetHeapGrowthStacks(&s); |
| 77 WriteStringToFile(s, string(argv[1]) + ".growth"); | 79 WriteStringToFile(s, string(argv[1]) + ".growth"); |
| 78 | 80 |
| 79 return 0; | 81 return 0; |
| 80 } | 82 } |
| OLD | NEW |