File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232
3333 # Reset this number to 0 on major V8 upgrades.
3434 # Increment by one for each non-official patch applied to deps/v8.
35- 'v8_embedder_string' : '-node.10 ' ,
35+ 'v8_embedder_string' : '-node.11 ' ,
3636
3737 # Enable disassembler for `--print-code` v8 options
3838 'v8_enable_disassembler' : 1 ,
Original file line number Diff line number Diff line change @@ -23,9 +23,14 @@ HeapProfiler::~HeapProfiler() = default;
2323
2424void HeapProfiler::DeleteAllSnapshots () {
2525 snapshots_.clear ();
26- names_. reset ( new StringsStorage () );
26+ MaybeClearStringsStorage ( );
2727}
2828
29+ void HeapProfiler::MaybeClearStringsStorage () {
30+ if (snapshots_.empty () && !sampling_heap_profiler_ && !allocation_tracker_) {
31+ names_.reset (new StringsStorage ());
32+ }
33+ }
2934
3035void HeapProfiler::RemoveSnapshot (HeapSnapshot* snapshot) {
3136 snapshots_.erase (
@@ -126,6 +131,7 @@ bool HeapProfiler::StartSamplingHeapProfiler(
126131
127132void HeapProfiler::StopSamplingHeapProfiler () {
128133 sampling_heap_profiler_.reset ();
134+ MaybeClearStringsStorage ();
129135}
130136
131137
@@ -159,6 +165,7 @@ void HeapProfiler::StopHeapObjectsTracking() {
159165 ids_->StopHeapObjectsTracking ();
160166 if (allocation_tracker_) {
161167 allocation_tracker_.reset ();
168+ MaybeClearStringsStorage ();
162169 heap ()->RemoveHeapObjectAllocationTracker (this );
163170 }
164171}
Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ class HeapProfiler : public HeapObjectAllocationTracker {
9292 v8::PersistentValueVector<v8::Object>* objects);
9393
9494 private:
95+ void MaybeClearStringsStorage ();
96+
9597 Heap* heap () const ;
9698
9799 // Mapping from HeapObject addresses to objects' uids.
Original file line number Diff line number Diff line change @@ -3900,3 +3900,45 @@ TEST(WeakReference) {
39003900 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot ();
39013901 CHECK (ValidateSnapshot (snapshot));
39023902}
3903+
3904+ TEST (Bug8373_1) {
3905+ LocalContext env;
3906+ v8::HandleScope scope (env->GetIsolate ());
3907+ v8::HeapProfiler* heap_profiler = env->GetIsolate ()->GetHeapProfiler ();
3908+
3909+ heap_profiler->StartSamplingHeapProfiler (100 );
3910+
3911+ heap_profiler->TakeHeapSnapshot ();
3912+ // Causes the StringsStorage to be deleted.
3913+ heap_profiler->DeleteAllHeapSnapshots ();
3914+
3915+ // Triggers an allocation sample that tries to use the StringsStorage.
3916+ for (int i = 0 ; i < 2 * 1024 ; ++i) {
3917+ CompileRun (
3918+ " new Array(64);"
3919+ " new Uint8Array(16);" );
3920+ }
3921+
3922+ heap_profiler->StopSamplingHeapProfiler ();
3923+ }
3924+
3925+ TEST (Bug8373_2) {
3926+ LocalContext env;
3927+ v8::HandleScope scope (env->GetIsolate ());
3928+ v8::HeapProfiler* heap_profiler = env->GetIsolate ()->GetHeapProfiler ();
3929+
3930+ heap_profiler->StartTrackingHeapObjects (true );
3931+
3932+ heap_profiler->TakeHeapSnapshot ();
3933+ // Causes the StringsStorage to be deleted.
3934+ heap_profiler->DeleteAllHeapSnapshots ();
3935+
3936+ // Triggers an allocations that try to use the StringsStorage.
3937+ for (int i = 0 ; i < 2 * 1024 ; ++i) {
3938+ CompileRun (
3939+ " new Array(64);"
3940+ " new Uint8Array(16);" );
3941+ }
3942+
3943+ heap_profiler->StopTrackingHeapObjects ();
3944+ }
You can’t perform that action at this time.
0 commit comments