< prev index next >

src/hotspot/share/runtime/os.cpp

Print this page




 651     ls.print_cr("## nof_mallocs = " UINT64_FORMAT ", nof_frees = " UINT64_FORMAT, os::num_mallocs, os::num_frees);
 652     ls.print_cr("## memory stomp:");
 653     guarded.print_on(&ls);
 654     fatal("memory stomping error");
 655   }
 656 }
 657 
 658 #endif
 659 
 660 //
 661 // This function supports testing of the malloc out of memory
 662 // condition without really running the system out of memory.
 663 //
 664 static bool has_reached_max_malloc_test_peak(size_t alloc_size) {
 665   if (MallocMaxTestWords > 0) {
 666     size_t words = (alloc_size / BytesPerWord);
 667 
 668     if ((cur_malloc_words + words) > MallocMaxTestWords) {
 669       return true;
 670     }
 671     Atomic::add(words, &cur_malloc_words);
 672   }
 673   return false;
 674 }
 675 
 676 void* os::malloc(size_t size, MEMFLAGS flags) {
 677   return os::malloc(size, flags, CALLER_PC);
 678 }
 679 
 680 void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
 681   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
 682   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
 683 
 684   // Since os::malloc can be called when the libjvm.{dll,so} is
 685   // first loaded and we don't have a thread yet we must accept NULL also here.
 686   assert(!os::ThreadCrashProtection::is_crash_protected(Thread::current_or_null()),
 687          "malloc() not allowed when crash protection is set");
 688 
 689   if (size == 0) {
 690     // return a valid pointer if size is zero
 691     // if NULL is returned the calling functions assume out of memory.




 651     ls.print_cr("## nof_mallocs = " UINT64_FORMAT ", nof_frees = " UINT64_FORMAT, os::num_mallocs, os::num_frees);
 652     ls.print_cr("## memory stomp:");
 653     guarded.print_on(&ls);
 654     fatal("memory stomping error");
 655   }
 656 }
 657 
 658 #endif
 659 
 660 //
 661 // This function supports testing of the malloc out of memory
 662 // condition without really running the system out of memory.
 663 //
 664 static bool has_reached_max_malloc_test_peak(size_t alloc_size) {
 665   if (MallocMaxTestWords > 0) {
 666     size_t words = (alloc_size / BytesPerWord);
 667 
 668     if ((cur_malloc_words + words) > MallocMaxTestWords) {
 669       return true;
 670     }
 671     Atomic::add(&cur_malloc_words, words);
 672   }
 673   return false;
 674 }
 675 
 676 void* os::malloc(size_t size, MEMFLAGS flags) {
 677   return os::malloc(size, flags, CALLER_PC);
 678 }
 679 
 680 void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) {
 681   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
 682   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
 683 
 684   // Since os::malloc can be called when the libjvm.{dll,so} is
 685   // first loaded and we don't have a thread yet we must accept NULL also here.
 686   assert(!os::ThreadCrashProtection::is_crash_protected(Thread::current_or_null()),
 687          "malloc() not allowed when crash protection is set");
 688 
 689   if (size == 0) {
 690     // return a valid pointer if size is zero
 691     // if NULL is returned the calling functions assume out of memory.


< prev index next >