hotspot/src/share/vm/services/mallocTracker.cpp
changeset 26925 c77fdcf78eeb
parent 25946 1572c9f03fb9
child 27162 0a4a7276949b
equal deleted inserted replaced
26922:8134a6d3fc02 26925:c77fdcf78eeb
   138 
   138 
   139   if (malloc_base == NULL) {
   139   if (malloc_base == NULL) {
   140     return NULL;
   140     return NULL;
   141   }
   141   }
   142 
   142 
   143   // Check malloc size, size has to <= MAX_MALLOC_SIZE. This is only possible on 32-bit
       
   144   // systems, when malloc size >= 1GB, but is is safe to assume it won't happen.
       
   145   if (size > MAX_MALLOC_SIZE) {
       
   146     fatal("Should not use malloc for big memory block, use virtual memory instead");
       
   147   }
       
   148   // Uses placement global new operator to initialize malloc header
   143   // Uses placement global new operator to initialize malloc header
   149   switch(level) {
   144   switch(level) {
   150     case NMT_off:
   145     case NMT_off:
   151       return malloc_base;
   146       return malloc_base;
   152     case NMT_minimal: {
   147     case NMT_minimal: {
   153       MallocHeader* hdr = ::new (malloc_base) MallocHeader();
   148       MallocHeader* hdr = ::new (malloc_base) MallocHeader();
   154       break;
   149       break;
   155     }
   150     }
   156     case NMT_summary: {
   151     case NMT_summary: {
       
   152       assert(size <= MAX_MALLOC_SIZE, "malloc size overrun for NMT");
   157       header = ::new (malloc_base) MallocHeader(size, flags);
   153       header = ::new (malloc_base) MallocHeader(size, flags);
   158       break;
   154       break;
   159     }
   155     }
   160     case NMT_detail: {
   156     case NMT_detail: {
       
   157       assert(size <= MAX_MALLOC_SIZE, "malloc size overrun for NMT");
   161       header = ::new (malloc_base) MallocHeader(size, flags, stack);
   158       header = ::new (malloc_base) MallocHeader(size, flags, stack);
   162       break;
   159       break;
   163     }
   160     }
   164     default:
   161     default:
   165       ShouldNotReachHere();
   162       ShouldNotReachHere();