Reducing module memory footprint

Xspeed

Senior Member
Jun 2, 2013
502
654
138
Hello fellow devs

It's a well known fact that all modules are loaded into all processes, even if they have nothing to do with them, which makes a pretty big difference if you have ~20 modules active and ~30 processes running.

Would something like this prevent the situation from happening?
Code:
public final class XposedInit implements IXposedHookLoadPackage
{
    // Only one field and one method which means small memory footprint?
    private IXposedHookLoadPackage mainModule = null;
    
    @Override
    public final void handleLoadPackage(final LoadPackageParam lpp) throws Throwable
    {
        // Hardcode the packages we really use
        if (lpp.packageName.equals("android") || lpp.packageName.equals(getClass().getPackage().getName()))
        {
            // Initialize the real part of the module only if it's really going to be used
            if (mainModule == null) mainModule = new MyMainGrandModule();
            mainModule.handleLoadPackage(lpp);
        }
    }
}
Any insight appreciated.