Skip to content

Commit 5959487

Browse files
committed
Use the dispatch_get_global_queue and call dispatch_release
1 parent c63350d commit 5959487

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lldb/tools/lldb-dap/MemoryMonitor.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ class MemoryMonitorDarwin : public MemoryMonitor {
3333
DISPATCH_SOURCE_TYPE_MEMORYPRESSURE,
3434
0, // system-wide monitoring
3535
DISPATCH_MEMORYPRESSURE_WARN | DISPATCH_MEMORYPRESSURE_CRITICAL,
36-
dispatch_get_main_queue());
36+
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
37+
38+
if (!m_memory_pressure_source)
39+
return;
3740

3841
dispatch_source_set_event_handler(m_memory_pressure_source, ^{
3942
dispatch_source_memorypressure_flags_t pressureLevel =
@@ -45,7 +48,12 @@ class MemoryMonitorDarwin : public MemoryMonitor {
4548
});
4649
}
4750

48-
void Stop() override { dispatch_source_cancel(m_memory_pressure_source); }
51+
void Stop() override {
52+
if (m_memory_pressure_source) {
53+
dispatch_source_cancel(m_memory_pressure_source);
54+
dispatch_release(m_memory_pressure_source);
55+
}
56+
}
4957

5058
private:
5159
dispatch_source_t m_memory_pressure_source;

0 commit comments

Comments
 (0)