Waypoint
Waypoint

Reputation: 17743

Android - get actual allocated RAM size

when I open new activities, I need to know my actual memory allocation (app can have huge memory allocation and I need to test real numbers). Is there any API for that?

Thanks

Edit code is not running... there is error on last line:

ActivityManager actvityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE );
    ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo ();
    actvityManager.getMemoryInfo( mInfo );

    List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();

    for(int i = 0; i < procInfos.size(); i++)
    {
        if(procInfos.get(i).processName.equals("cz.process.a")) {
            int  field[]=new int []{procInfos.get(i).pid};
            android.os.Debug.MemoryInfo[] info = actvityManager.getProcessMemoryInfo(field);

Still not solved. There was someone, who was an expert. But he offered me a code and wasn't able to describe it. He suggested code above, but on the last line there is a critical error.

Upvotes: 0

Views: 667

Answers (1)

Michael
Michael

Reputation: 54705

I believe Debug and Debug.MemoryInfo classes can help you.

Upvotes: 1

Related Questions