Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a661509 authored by Shai Barack's avatar Shai Barack
Browse files

Round up to the nearest page size when registering native memory with the VM.

The underlying allocation is a virtual allocation, so it's given in page increments.

Flag: EXEMPT bugfix
Bug: 361329788
Change-Id: Ia3bfdd25ac7d4cd123ef3bd1b6dcc6e32085f230
parent f2767e98
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -379,6 +379,12 @@ public final class SharedMemory implements Parcelable, Closeable {
        private int mReferenceCount;

        private MemoryRegistration(int size) {
            // Round up to the nearest page size
            final int PAGE_SIZE = OsConstants._SC_PAGE_SIZE;
            final int remainder = size % PAGE_SIZE;
            if (remainder != 0) {
                size += PAGE_SIZE - remainder;
            }
            mSize = size;
            mReferenceCount = 1;
            VMRuntime.getRuntime().registerNativeAllocation(mSize);