comparison src/share/vm/memory/allocation.inline.hpp @ 10161:746b070f5022

8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap" Reviewed-by: coleenp, zgu, hseigel
author ccheung
date Tue, 30 Apr 2013 11:56:52 -0700
parents 5a9fa2ba85f0
children c18152e0554e
comparison
equal deleted inserted replaced
10160:ed5a590835a4 10161:746b070f5022
56 } 56 }
57 char* p = (char*) os::malloc(size, flags, pc); 57 char* p = (char*) os::malloc(size, flags, pc);
58 #ifdef ASSERT 58 #ifdef ASSERT
59 if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p); 59 if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p);
60 #endif 60 #endif
61 if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) vm_exit_out_of_memory(size, "AllocateHeap"); 61 if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
62 vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
63 }
62 return p; 64 return p;
63 } 65 }
64 66
65 inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags, 67 inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags,
66 AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { 68 AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
67 char* p = (char*) os::realloc(old, size, flags, CURRENT_PC); 69 char* p = (char*) os::realloc(old, size, flags, CURRENT_PC);
68 #ifdef ASSERT 70 #ifdef ASSERT
69 if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p); 71 if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p);
70 #endif 72 #endif
71 if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) vm_exit_out_of_memory(size, "ReallocateHeap"); 73 if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
74 vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
75 }
72 return p; 76 return p;
73 } 77 }
74 78
75 inline void FreeHeap(void* p, MEMFLAGS memflags = mtInternal) { 79 inline void FreeHeap(void* p, MEMFLAGS memflags = mtInternal) {
76 #ifdef ASSERT 80 #ifdef ASSERT
128 int alignment = os::vm_allocation_granularity(); 132 int alignment = os::vm_allocation_granularity();
129 _size = align_size_up(_size, alignment); 133 _size = align_size_up(_size, alignment);
130 134
131 _addr = os::reserve_memory(_size, NULL, alignment); 135 _addr = os::reserve_memory(_size, NULL, alignment);
132 if (_addr == NULL) { 136 if (_addr == NULL) {
133 vm_exit_out_of_memory(_size, "Allocator (reserve)"); 137 vm_exit_out_of_memory(_size, OOM_MMAP_ERROR, "Allocator (reserve)");
134 } 138 }
135 139
136 bool success = os::commit_memory(_addr, _size, false /* executable */); 140 bool success = os::commit_memory(_addr, _size, false /* executable */);
137 if (!success) { 141 if (!success) {
138 vm_exit_out_of_memory(_size, "Allocator (commit)"); 142 vm_exit_out_of_memory(_size, OOM_MMAP_ERROR, "Allocator (commit)");
139 } 143 }
140 144
141 return (E*)_addr; 145 return (E*)_addr;
142 } 146 }
143 147