void MemoryPressureHandler::ReliefLogger::logMemoryUsageChange() { #if PLATFORM(WPE) #define STRING_SPECIFICATION "%s" #define MEMORYPRESSURE_LOG(...) LOG(MemoryPressure, __VA_ARGS__) #elif !RELEASE_LOG_DISABLED #define STRING_SPECIFICATION "%{public}s" #define MEMORYPRESSURE_LOG(...) RELEASE_LOG(__VA_ARGS__) #else #define STRING_SPECIFICATION "%s" #define MEMORYPRESSURE_LOG(...) WTFLogAlways(__VA_ARGS__) #endif size_t currentMemory = platformMemoryUsage(); if (currentMemory == static_cast<size_t>(-1) || m_initialMemory == static_cast<size_t>(-1)) { MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": (Unable to get dirty memory information for process)", m_logString); return; } long memoryDiff = currentMemory - m_initialMemory; if (memoryDiff < 0) MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": -dirty %ld bytes (from %zu to %zu)", m_logString, (memoryDiff * -1), m_initialMemory, currentMemory); else if (memoryDiff > 0) MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": +dirty %ld bytes (from %zu to %zu)", m_logString, memoryDiff, m_initialMemory, currentMemory); else MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": =dirty (at %zu bytes)", m_logString, currentMemory); }
void MemoryPressureHandler::ReliefLogger::platformLog() { size_t currentMemory = platformMemoryUsage(); if (currentMemory == static_cast<size_t>(-1) || m_initialMemory == static_cast<size_t>(-1)) { LOG(MemoryPressure, "%s (Unable to get dirty memory information for process)", m_logString); return; } ssize_t memoryDiff = currentMemory - m_initialMemory; if (memoryDiff < 0) LOG(MemoryPressure, "Pressure relief: %s: -dirty %lu bytes (from %lu to %lu)", m_logString, static_cast<unsigned long>(memoryDiff * -1), static_cast<unsigned long>(m_initialMemory), static_cast<unsigned long>(currentMemory)); else if (memoryDiff > 0) LOG(MemoryPressure, "Pressure relief: %s: +dirty %lu bytes (from %lu to %lu)", m_logString, static_cast<unsigned long>(memoryDiff), static_cast<unsigned long>(m_initialMemory), static_cast<unsigned long>(currentMemory)); else LOG(MemoryPressure, "Pressure relief: %s: =dirty (at %lu bytes)", m_logString, static_cast<unsigned long>(currentMemory)); }