< prev index next >

src/share/vm/gc/shared/collectedHeap.cpp

Print this page
rev 13139 : [mq]: heap7
rev 13140 : [mq]: heapz8

@@ -309,20 +309,23 @@
         thread->tlab().set_back_actual_end();
         obj = thread->tlab().allocate(size);
       }
 
       // Is the object allocated now?
+      // If not, this means we have to wait till a new TLAB, let the subsequent
+      // call to handle_heap_sampling pick the next sample.
       if (obj != NULL) {
         // Object is allocated, sample it now.
         HeapMonitoring::object_alloc_do_sample(thread,
                                                reinterpret_cast<oopDesc*>(obj),
                                                size);
+        // Pick a next sample in this case, we allocated right.
+        thread->tlab().pick_next_sample();
       }
     }
   }
 
-  thread->tlab().pick_next_sample();
   return obj;
 }
 
 HeapWord* CollectedHeap::allocate_from_tlab_slow(Klass* klass, Thread* thread, size_t size) {
   HeapWord* obj = handle_heap_sampling(thread, NULL, size);
< prev index next >