diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibC/malloc.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibC/sys/mman.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Bitmap.cpp | 5 |
3 files changed, 5 insertions, 3 deletions
diff --git a/Userland/Libraries/LibC/malloc.cpp b/Userland/Libraries/LibC/malloc.cpp index 9c412c55cf..086c86c411 100644 --- a/Userland/Libraries/LibC/malloc.cpp +++ b/Userland/Libraries/LibC/malloc.cpp @@ -158,7 +158,7 @@ extern "C" { static void* os_alloc(size_t size, const char* name) { - auto* ptr = serenity_mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, ChunkedBlock::block_size, name); + auto* ptr = serenity_mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_PURGEABLE, 0, 0, ChunkedBlock::block_size, name); VERIFY(ptr != MAP_FAILED); return ptr; } diff --git a/Userland/Libraries/LibC/sys/mman.h b/Userland/Libraries/LibC/sys/mman.h index d2638bd03f..be135ab93d 100644 --- a/Userland/Libraries/LibC/sys/mman.h +++ b/Userland/Libraries/LibC/sys/mman.h @@ -18,6 +18,7 @@ #define MAP_STACK 0x40 #define MAP_NORESERVE 0x80 #define MAP_RANDOMIZED 0x100 +#define MAP_PURGEABLE 0x200 #define PROT_READ 0x1 #define PROT_WRITE 0x2 diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index 8d8f4b87b7..da121366f0 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -544,11 +544,11 @@ void Bitmap::set_volatile() int rc = madvise(m_data, size_in_bytes(), MADV_SET_NONVOLATILE); if (rc < 0) { if (errno == ENOMEM) { - was_purged = was_purged_int; + was_purged = true; return false; } - perror("madvise(MADV_SET_NONVOLATILE)"); + VERIFY_NOT_REACHED(); } was_purged = rc != 0; #endif @@ -574,6 +574,7 @@ Optional<BackingStore> Bitmap::try_allocate_backing_store(BitmapFormat format, I int map_flags = MAP_ANONYMOUS | MAP_PRIVATE; #ifdef __serenity__ + map_flags |= MAP_PURGEABLE; void* data = mmap_with_name(nullptr, data_size_in_bytes, PROT_READ | PROT_WRITE, map_flags, 0, 0, String::formatted("GraphicsBitmap [{}]", size).characters()); #else void* data = mmap(nullptr, data_size_in_bytes, PROT_READ | PROT_WRITE, map_flags, 0, 0); |