comparison src/share/vm/services/diagnosticArgument.hpp @ 6197:d2a62e0f25eb

6995781: Native Memory Tracking (Phase 1) 7151532: DCmd for hotspot native memory tracking Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd Reviewed-by: acorn, coleenp, fparain
author zgu
date Thu, 28 Jun 2012 17:03:16 -0400
parents 51612f0c0a79
children
comparison
equal deleted inserted replaced
6174:74533f63b116 6197:d2a62e0f25eb
29 #include "memory/allocation.hpp" 29 #include "memory/allocation.hpp"
30 #include "runtime/os.hpp" 30 #include "runtime/os.hpp"
31 #include "runtime/thread.hpp" 31 #include "runtime/thread.hpp"
32 #include "utilities/exceptions.hpp" 32 #include "utilities/exceptions.hpp"
33 33
34 class StringArrayArgument : public CHeapObj { 34 class StringArrayArgument : public CHeapObj<mtInternal> {
35 private: 35 private:
36 GrowableArray<char*>* _array; 36 GrowableArray<char*>* _array;
37 public: 37 public:
38 StringArrayArgument() { 38 StringArrayArgument() {
39 _array = new(ResourceObj::C_HEAP)GrowableArray<char *>(32, true); 39 _array = new(ResourceObj::C_HEAP, mtInternal)GrowableArray<char *>(32, true);
40 assert(_array != NULL, "Sanity check"); 40 assert(_array != NULL, "Sanity check");
41 } 41 }
42 void add(const char* str, size_t len) { 42 void add(const char* str, size_t len) {
43 if (str != NULL) { 43 if (str != NULL) {
44 char* ptr = NEW_C_HEAP_ARRAY(char, len+1); 44 char* ptr = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
45 strncpy(ptr, str, len); 45 strncpy(ptr, str, len);
46 ptr[len] = 0; 46 ptr[len] = 0;
47 _array->append(ptr); 47 _array->append(ptr);
48 } 48 }
49 } 49 }
51 return _array; 51 return _array;
52 } 52 }
53 ~StringArrayArgument() { 53 ~StringArrayArgument() {
54 for (int i=0; i<_array->length(); i++) { 54 for (int i=0; i<_array->length(); i++) {
55 if(_array->at(i) != NULL) { // Safety check 55 if(_array->at(i) != NULL) { // Safety check
56 FREE_C_HEAP_ARRAY(char, _array->at(i)); 56 FREE_C_HEAP_ARRAY(char, _array->at(i), mtInternal);
57 } 57 }
58 } 58 }
59 delete _array; 59 delete _array;
60 } 60 }
61 }; 61 };