Chion82 / WeChatMomentStat-Android

Get your WeChat Moment statistics and export Moments to JSON. 微信朋友圈数据统计、导出工具
GNU General Public License v3.0
981 stars 261 forks source link

There are some advices for your program #11

Open slankka opened 8 years ago

slankka commented 8 years ago

Your program is interesting.But on my device, when I click share button, the program FC. In the console, I got these:

moe.chionlab.wechatmomentstat E/AndroidRuntime: 
FATAL EXCEPTION: main
    Process: moe.chionlab.wechatmomentstat, PID: 12892
    java.lang.OutOfMemoryError
    at android.graphics.Bitmap.nativeCreate(Native Method)
    ...
    at moe.chionlab.wechatmomentstat.gui.MomentStatActivity.
generateShareImage(MomentStatActivity.java:207)

and you should release memory after you use Bitmap. Here are my advices:

  1. in AndroidManifest.xml android:largeHeap="true"
  2. in generateShareImage.java (227) add these code:
finally {
            if(cs!=null){
                cs.setBitmap(null);
                cs=null;
            }
            if(dest!=null){
                dest.recycle();
                dest = null;
            }
            if(src!=null){
                src.recycle();
                src = null;
            }
        }

The memory allocated for bitmap will be free after about 20s.

Chion82 commented 8 years ago

Thanks for your advices. It would be great if you could create a pull request for us to solve this problem. Yeah I should have noticed the memory allocation problem.