Skip to content

Commit fd8f6f6

Browse files
committed
Continued work on memory pressure handling
1 parent 498e15b commit fd8f6f6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

scopehal/scopehal.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ vector<string> g_searchPaths;
132132

133133
void VulkanCleanup();
134134

135+
///@brief List of handlers for low memory registered by various subsystems
136+
set<MemoryPressureHandler> g_memoryPressureHandlers;
137+
135138
/**
136139
@brief Static initialization for SCPI transports
137140
*/
@@ -996,6 +999,11 @@ const char* ScopehalGetVersion()
996999
*/
9971000
void OnMemoryPressure(MemoryPressureLevel level, MemoryPressureType type)
9981001
{
1002+
LogWarning("OnMemoryPressure: %s memory exhaustion on %s\n",
1003+
(level == MemoryPressureLevel::Hard) ? "Hard" : "Soft",
1004+
(type == MemoryPressureType::Host) ? "host" : "device");
1005+
LogIndenter li;
1006+
9991007
for(auto handler : g_memoryPressureHandlers)
10001008
handler(level, type);
10011009
}

scopehal/scopehal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,7 @@ enum class MemoryPressureType
302302
///@brief Memory pressure handler type, called when free memory reaches a warning level or a Vulkan allocation fails
303303
typedef void (*MemoryPressureHandler)(MemoryPressureLevel level, MemoryPressureType type);
304304

305-
///@brief List of handlers for low memory registered by various subsystems
306-
std::set<MemoryPressureHandler> g_memoryPressureHandlers;
305+
extern std::set<MemoryPressureHandler> g_memoryPressureHandlers;
307306

308307
void OnMemoryPressure(MemoryPressureLevel level, MemoryPressureType type);
309308

0 commit comments

Comments
 (0)