-
Notifications
You must be signed in to change notification settings - Fork 7
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
Your project has OOM problem #1
Comments
Thanks, hope you find it useful! I will look at the memory issues later - what do you recommend for better bitmap handling? |
In my opinion, you should recycle the old bitmap when a new one has been produced. Modification in MainActivity just like below: Bitmap bit; //a member of the activity public void nextPicture() {
} other suggestions:
wish it can help you. |
Thanks for the suggestions - I have used .recycle() and an Async task. What's the advantage of using decodeFileDescriptor instead of decodeFile? |
If you read the source code, it is clear that using decodeFile() is nearly equal to using decodeStream(), which is called by decodeFile() directly. However, decodeFile()/decodeStream() and decodeFileDescriptor() call different nativeDecodeXXX method. To someone's view, the nativeDecodeXXX used by decodeFileDescriptor() can consume less memory than the one called by decodeFile()/decodeStream(). I am not so sure if it is right. You can refer to this: http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object Another referable fact is an example from google developers: http://developer.android.com/training/displaying-bitmaps/index.html, you can download the demo project(BitmapFun), and what you can find clearly is that google developers avoid using decodeFile()/decodeStream() but instead use decodeFileDescriptor(). hope it is usable, thanks! |
hi, i tested this project, which has a good implementation of shake detection! But i'm so confused that didn't you discover your project can easily lead to OOM (Out of Memory)? As the ddms showed, it is likely to be caused by using bitmap inefficiently.
The text was updated successfully, but these errors were encountered: