I need to free below pointers, how to release memory for canvas, paint and matrix?
Canvas pcanvas = new Canvas(); Paint mPaint = new Paint(); Matrix matrix = new Matrix();
Thanks in advance.
Java does not have pointers and you cannot explicitly release memory.
However it is possible to leak memory in Java and Android. If any of your objects reference unmanaged memory, you need to let them know when they can release that memory.
Because it appears that you're doing graphics related work, I'd guess that you're using Bitmaps somewhere and these use a lot of memory and the memory needs to be released. When you're finished using a bitmap, make sure you call
after you are not more referencing the object you created, assign it the null value. That obviously does not release immediately the memory but int this way you are telling to the GC that the object is eligible for garbage collection.. (effective java).
Edit: as @spatulamania said, if you are managing bitmap you have to call the recycle (it call a c/c++ free I think) method in order to free memory associated with. Set to null a bitmap reference is not useful because the bitmap is native implemented and the java object is few bytes.