Loading...
Logo
Processing Forum
Hi

EDIT: Solved... also needed to create an ActivityManager. The code now shows me memory info although totalMem is still a problem... but one I can live with. 

Anyone done any fiddling with memory management for android? I have just started but have hit a problem straight off!

In the code below, I am simply printing the MemoryInfo fields 

The first 3 work, but the myMemInfo.totalMem field generates an error.

Also, any explanations as to why myMemInfo.availMem has the value zero?

Any ideas/thoughts?
Copy code
  1. import android.app.ActivityManager.MemoryInfo ;
  2. import android.app.ActivityManager;

  3. MemoryInfo myMemInfo ;
  4. ActivityManager myActivityManager ;

  5. void setup(){
  6.  myMemInfo = new MemoryInfo();
  7.  myActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  8.  myActivityManager.getMemoryInfo(myMemInfo);
  9.  println("availMem = " + myMemInfo.availMem);

  10.  println("lowMemory = " + myMemInfo.lowMemory);
  11.  println("threshold = " + myMemInfo.threshold);
  12.  println("totalMemory = " + myMemInfo.totalMem);
  13. }

  14. void draw(){
  15. }

Cheers
Mark