Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are some advices for your program #11

Open
slankka opened this issue Aug 27, 2016 · 1 comment
Open

There are some advices for your program #11

slankka opened this issue Aug 27, 2016 · 1 comment

Comments

@slankka
Copy link

slankka commented Aug 27, 2016

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.

@slankka slankka changed the title There are some advices for you program There are some advices for your program Aug 27, 2016
@Chion82
Copy link
Owner

Chion82 commented Aug 27, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants