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

Commit ec5dcca5 authored by T.J. Mercier's avatar T.J. Mercier
Browse files

Adjust procfs heap buffer growth limit to 64 MiB

The current 1 GiB limit is excessive, and would result in extreme
amounts of copying for very large files. Files read by
android_os_Process_readProcFile should be well under this new limit,
and most should only use the stack buffer anyways.

Bug: 351917521
Test: cuttlefish boot
Change-Id: I37da934b5e66d9b56da928dabd7e115e2ed6dca7
parent 8fdaa6ea
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1094,7 +1094,8 @@ jboolean android_os_Process_readProcFile(JNIEnv* env, jobject clazz,
                static_assert(kProcReadMinHeapBufferSize > sizeof(stackBuf));
                std::memcpy(heapBuf.data(), stackBuf, sizeof(stackBuf));
            } else {
                if (heapBuf.size() >= std::numeric_limits<ssize_t>::max() / 2) {
                constexpr size_t MAX_READABLE_PROCFILE_SIZE = 64 << 20;
                if (heapBuf.size() >= MAX_READABLE_PROCFILE_SIZE) {
                    if (kDebugProc) {
                        ALOGW("Proc file too big: %s fd=%d size=%zu\n",
                              file8.get(), fd.get(), heapBuf.size());