Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak detection #495

Open
nmweizi opened this issue Dec 4, 2023 · 0 comments
Open

Memory leak detection #495

nmweizi opened this issue Dec 4, 2023 · 0 comments

Comments

@nmweizi
Copy link

nmweizi commented Dec 4, 2023

hi,
Use the frida-gadget.dylib hook macos program to execute the javascript script. After running for a long time, the memory keeps growing. It seems that the written script has a memory leak.

In this injection environment, how to detect memory usage and leakage?

When not hooked, the memory is normal.
frida-gadget.dylib 16.1.8
macos 14.1 intel

const NSNumber = ObjC.classes.NSNumber;
const NSNumber_0 = NSNumber.alloc().initWithInt_(0);

var get_item = {"bb":NSNumber_0};

var objectForKeyedSubscript = ObjC.classes.NSDictionary["- objectForKeyedSubscript:"];

Interceptor.attach(objectForKeyedSubscript.implementation, {
    onEnter(args) {
        this.key = new ObjC.Object(ptr(args[2])).toString();
    },
    onLeave: function (retval) {
        var result = get_item[this.key];
        if (result) {
            retval.replace(result);
        }
        this.key = null;
    }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant