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

Commit 53541296 authored by Andy Hung's avatar Andy Hung
Browse files

Add memory leak detection to mediaserver

Bug: 28169802
Change-Id: I05e12ef3b12c5f0322ddf5ecc10d95205b0e44d6
parent 0c4a97e6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ LOCAL_SHARED_LIBRARIES := \
    libgui                      \
    libmedia                    \
    libmediautils               \
    libmemunreachable           \
    libsonivox                  \
    libstagefright              \
    libstagefright_foundation   \
@@ -54,6 +55,7 @@ LOCAL_C_INCLUDES := \
    $(TOP)/frameworks/av/include/camera                             \
    $(TOP)/frameworks/native/include/media/openmax                  \
    $(TOP)/external/tremolo/Tremolo                                 \
    libcore/include                                                 \

LOCAL_CFLAGS += -Werror -Wno-error=deprecated-declarations -Wall
LOCAL_CLANG := true
+10 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@
#include <media/stagefright/foundation/ALooperRoster.h>
#include <mediautils/BatteryNotifier.h>

#include <memunreachable/memunreachable.h>
#include <system/audio.h>

#include <private/android_filesystem_config.h>
@@ -536,14 +537,23 @@ status_t MediaPlayerService::dump(int fd, const Vector<String16>& args)
        gLooperRoster.dump(fd, args);

        bool dumpMem = false;
        bool unreachableMemory = false;
        for (size_t i = 0; i < args.size(); i++) {
            if (args[i] == String16("-m")) {
                dumpMem = true;
            } else if (args[i] == String16("--unreachable")) {
                unreachableMemory = true;
            }
        }
        if (dumpMem) {
            dumpMemoryAddresses(fd);
        }
        if (unreachableMemory) {
            result.append("\nDumping unreachable memory:\n");
            // TODO - should limit be an argument parameter?
            std::string s = GetUnreachableMemoryString(true /* contents */, 10000 /* limit */);
            result.append(s.c_str(), s.size());
        }
    }
    write(fd, result.string(), result.size());
    return NO_ERROR;