Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/WTF/wtf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ set(WTF_LIBRARIES
ICU::data
ICU::i18n
ICU::uc
gpumem
)

if (NOT USE_SYSTEM_MALLOC)
Expand Down
24 changes: 9 additions & 15 deletions Source/WTF/wtf/MemoryPressureHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "config.h"
#include <wtf/MemoryPressureHandler.h>
#include <gpumem.h>

#if OS(LINUX)
#include <unistd.h>
Expand Down Expand Up @@ -91,21 +92,11 @@ static bool isWebProcess()

static size_t memoryFootprintVideo()
{
if (!isWebProcess() || s_GPUMemoryFile.isEmpty())
return 0;

FILE* file = fopen(s_GPUMemoryFile.utf8().data(), "r");
if (!file)
return 0;

char* buffer = nullptr;
size_t size = 0;
uint32_t totalMemory = 0, availableMemory = 0;
size_t footprint = 0;
if (getline(&buffer, &size, file) != -1)
sscanf(buffer, "%u", &footprint);

free(buffer);
fclose(file);
if (gpumem_video_memory_total(&totalMemory) == 0 && gpumem_video_memory_available(0, &availableMemory) == 0) {
footprint = (totalMemory - availableMemory);
}

return footprint;
}
Expand Down Expand Up @@ -322,7 +313,10 @@ void MemoryPressureHandler::measurementTimerFired()
static size_t footprintPeak = 0;
if (footprintPeak < footprint)
footprintPeak = footprint;
RELEASE_LOG(MemoryPressure, "Current memory footprint: %zu MB, peak: %zu MB, video footprint: %zu MB", footprint / MB, footprintPeak / MB, footprintVideo / MB);
if (isWebProcess())
RELEASE_LOG(MemoryPressure, "Current memory footprint: %zu MB, peak: %zu MB, video footprint: %zu MB", footprint / MB, footprintPeak / MB, footprintVideo / MB);
else
RELEASE_LOG(MemoryPressure, "Current memory footprint: %zu MB, peak: %zu MB", footprint / MB, footprintPeak / MB);
auto killThreshold = thresholdForMemoryKill(MemoryType::Normal);
auto killThresholdVideo = thresholdForMemoryKill(MemoryType::Video);
if ((killThreshold && footprint >= *killThreshold) || (killThresholdVideo && footprintVideo >= *killThresholdVideo)) {
Expand Down