File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333
3434 # Reset this number to 0 on major V8 upgrades.
3535 # Increment by one for each non-official patch applied to deps/v8.
36- 'v8_embedder_string' : '-node.46 ' ,
36+ 'v8_embedder_string' : '-node.12 ' ,
3737
3838 # Enable disassembler for `--print-code` v8 options
3939 '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 @@ -3690,3 +3690,45 @@ TEST(WeakReference) {
36903690 const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot ();
36913691 CHECK (ValidateSnapshot (snapshot));
36923692}
3693+
3694+ TEST (Bug8373_1) {
3695+ LocalContext env;
3696+ v8::HandleScope scope (env->GetIsolate ());
3697+ v8::HeapProfiler* heap_profiler = env->GetIsolate ()->GetHeapProfiler ();
3698+
3699+ heap_profiler->StartSamplingHeapProfiler (100 );
3700+
3701+ heap_profiler->TakeHeapSnapshot ();
3702+ // Causes the StringsStorage to be deleted.
3703+ heap_profiler->DeleteAllHeapSnapshots ();
3704+
3705+ // Triggers an allocation sample that tries to use the StringsStorage.
3706+ for (int i = 0 ; i < 2 * 1024 ; ++i) {
3707+ CompileRun (
3708+ " new Array(64);"
3709+ " new Uint8Array(16);" );
3710+ }
3711+
3712+ heap_profiler->StopSamplingHeapProfiler ();
3713+ }
3714+
3715+ TEST (Bug8373_2) {
3716+ LocalContext env;
3717+ v8::HandleScope scope (env->GetIsolate ());
3718+ v8::HeapProfiler* heap_profiler = env->GetIsolate ()->GetHeapProfiler ();
3719+
3720+ heap_profiler->StartTrackingHeapObjects (true );
3721+
3722+ heap_profiler->TakeHeapSnapshot ();
3723+ // Causes the StringsStorage to be deleted.
3724+ heap_profiler->DeleteAllHeapSnapshots ();
3725+
3726+ // Triggers an allocations that try to use the StringsStorage.
3727+ for (int i = 0 ; i < 2 * 1024 ; ++i) {
3728+ CompileRun (
3729+ " new Array(64);"
3730+ " new Uint8Array(16);" );
3731+ }
3732+
3733+ heap_profiler->StopTrackingHeapObjects ();
3734+ }
You can’t perform that action at this time.
0 commit comments