comparison src/share/vm/memory/resourceArea.hpp @ 6872:7b5885dadbdc

8000617: It should be possible to allocate memory without the VM dying. Reviewed-by: coleenp, kamg
author nloodin
date Wed, 17 Oct 2012 17:36:48 +0200
parents d2a62e0f25eb
children 716c64bda5ba
comparison
equal deleted inserted replaced
6871:045cb62046a7 6872:7b5885dadbdc
66 66
67 ResourceArea(size_t init_size) : Arena(init_size) { 67 ResourceArea(size_t init_size) : Arena(init_size) {
68 debug_only(_nesting = 0;); 68 debug_only(_nesting = 0;);
69 } 69 }
70 70
71 char* allocate_bytes(size_t size) { 71 char* allocate_bytes(size_t size, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
72 #ifdef ASSERT 72 #ifdef ASSERT
73 if (_nesting < 1 && !_warned++) 73 if (_nesting < 1 && !_warned++)
74 fatal("memory leak: allocating without ResourceMark"); 74 fatal("memory leak: allocating without ResourceMark");
75 if (UseMallocOnly) { 75 if (UseMallocOnly) {
76 // use malloc, but save pointer in res. area for later freeing 76 // use malloc, but save pointer in res. area for later freeing
77 char** save = (char**)internal_malloc_4(sizeof(char*)); 77 char** save = (char**)internal_malloc_4(sizeof(char*));
78 return (*save = (char*)os::malloc(size, mtThread)); 78 return (*save = (char*)os::malloc(size, mtThread));
79 } 79 }
80 #endif 80 #endif
81 return (char*)Amalloc(size); 81 return (char*)Amalloc(size, alloc_failmode);
82 } 82 }
83 83
84 debug_only(int nesting() const { return _nesting; }); 84 debug_only(int nesting() const { return _nesting; });
85 }; 85 };
86 86