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 23 matching lines...) Expand all Loading... |
34 // by doing a bunch of allocations and then calling those functions. | 34 // by doing a bunch of allocations and then calling those functions. |
35 // A driver shell-script can call this, and then call pprof, and | 35 // A driver shell-script can call this, and then call pprof, and |
36 // verify the expected output. The output is written to | 36 // verify the expected output. The output is written to |
37 // argv[1].heap and argv[1].growth | 37 // argv[1].heap and argv[1].growth |
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 <gperftools/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; | 48 extern "C" void* AllocateAllocate() ATTRIBUTE_NOINLINE; |
49 | 49 |
50 extern "C" void* AllocateAllocate() { | 50 extern "C" void* AllocateAllocate() { |
51 // The VLOG's are mostly to discourage inlining | 51 // The VLOG's are mostly to discourage inlining |
52 VLOG(1, "Allocating some more"); | 52 VLOG(1, "Allocating some more"); |
53 void* p = malloc(10000); | 53 void* p = malloc(10000); |
54 VLOG(1, "Done allocating"); | 54 VLOG(1, "Done allocating"); |
(...skipping 18 matching lines...) Expand all Loading... |
73 string s; | 73 string s; |
74 MallocExtension::instance()->GetHeapSample(&s); | 74 MallocExtension::instance()->GetHeapSample(&s); |
75 WriteStringToFile(s, string(argv[1]) + ".heap"); | 75 WriteStringToFile(s, string(argv[1]) + ".heap"); |
76 | 76 |
77 s.clear(); | 77 s.clear(); |
78 MallocExtension::instance()->GetHeapGrowthStacks(&s); | 78 MallocExtension::instance()->GetHeapGrowthStacks(&s); |
79 WriteStringToFile(s, string(argv[1]) + ".growth"); | 79 WriteStringToFile(s, string(argv[1]) + ".growth"); |
80 | 80 |
81 return 0; | 81 return 0; |
82 } | 82 } |
OLD | NEW |