diff --git a/src/system/libroot/posix/malloc/openbsd/PagesAllocator.cpp b/src/system/libroot/posix/malloc/openbsd/PagesAllocator.cpp index 60f06e5c22..816e133f2c 100644 --- a/src/system/libroot/posix/malloc/openbsd/PagesAllocator.cpp +++ b/src/system/libroot/posix/malloc/openbsd/PagesAllocator.cpp @@ -32,6 +32,9 @@ static const size_t kReserveAddressSpace = 128 * 1024 * 1024; /*! Cache up to this many percentage points of free memory (compared to used.) */ static const size_t kFreePercentage = 25; +/*! Always forbid more free memory than this, even if it's below kFreePercentage. */ +static const size_t kFreeMaximum = 128 * 1024 * 1024; + /*! Always allow this much free memory, even if it's above kFreePercentage. */ static const size_t kFreeMinimum = 128 * kPageSize; @@ -252,6 +255,7 @@ public: } chunk = previousChunk; } + status_t status = _UnlockingRemoveAndUnmap(chunk); if (status != B_OK) return status; @@ -320,6 +324,8 @@ private: size_t freeLimit = ((fUsed * kFreePercentage) / 100); if (freeLimit < kFreeMinimum) freeLimit = kFreeMinimum; + else if (freeLimit > kFreeMaximum) + freeLimit = kFreeMaximum; else freeLimit = (freeLimit + (kPageSize - 1)) & ~(kPageSize - 1); return freeLimit;