Skip to content
This repository has been archived by the owner on Apr 24, 2018. It is now read-only.

Creating multiple instances of a ShowcaseView crashes the application with an outOfMemory error. #183

Closed
AMRoche opened this issue May 20, 2014 · 16 comments

Comments

@AMRoche
Copy link

AMRoche commented May 20, 2014

Stack Trace: 05-20 17:59:09.166 30218-30218/com.******_._***** E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:726)
at android.graphics.Bitmap.createBitmap(Bitmap.java:703)
at android.graphics.Bitmap.createBitmap(Bitmap.java:670)
at com.github.amlcurran.showcaseview.ShowcaseView.updateBitmap(ShowcaseView.java:202)
at com.github.amlcurran.showcaseview.ShowcaseView.onGlobalLayout(ShowcaseView.java:370)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:839)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2050)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6364)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:561)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
at dalvik.system.NativeStart.main(Native Method)

Steps to reproduce:
Create six separate instances of a ShowcaseView in four different views using the procedure detailed in the README.md.

Noted, this could be an application specific issue, however memory usage continually rises each time a ShowcaseView is created.

Device:
Galaxy S3 LTE, GT-I9305 running Android 4.3

@amlcurran
Copy link
Owner

Yeah, thought I had sorted this but apparently not. I'll take a look!

@AMRoche
Copy link
Author

AMRoche commented May 20, 2014

@amlcurran : I'm referencing 5.0.0-SNAPSHOT in the Gradle.build file. Am I using an old version maybe? I couldn't find a better reference sadly. If i've got the version wrong I can change that and let you know!

@amlcurran
Copy link
Owner

No that is the right version. I'm made it such that it should free memory when you hide a ShowcaseView, I'll push that soon and if you try using the latest snapshot tomorrow, can you let me know if it works for you?

@AMRoche
Copy link
Author

AMRoche commented May 20, 2014

Ah fantastic, will give that a go tomorrow and let you know! Thank you!

@AMRoche
Copy link
Author

AMRoche commented May 21, 2014

Heya, sorry for the no reply! Got around to trying it, sadly the same error with the same stack trace today despite having been using the newer snapshot!

@SimonRolin
Copy link

Same for me...

@AntonKosov
Copy link

I have the same problem.
Version: 5.0.0-SNAPSHOT (downloads today)

Android emulator:
Device: Nexus 7 (7.02'', 1200 x 1920: xhdpi)
Target: Android 4.2.2 - API Level 17
CPU/ABI: Intel Atom (x86)
RAM: 1024
VM Heap: 32
Use Host GPU

@SimonRolin
Copy link

I seems like the recycle() function is not working well. What I had to do to fix it is add a method to set by my own the bitmapBuffer. Also I could only call the .recycle() on the onDestroy() of my activity.
Not a perfect solution but anyway it is working...

@eygraber
Copy link

I'm having this issue as well (I display another ShowcaseView when the button on my first one is clicked). I can't consistently repro it, but it's showing up in my crash logs. One fix might be to call System.gc() in clearBitmap() (even though some people get squeamish about calling it, I've found it helps when create large bitmaps in a short period of time).

private void clearBitmap() {
    if (bitmapBuffer != null && !bitmapBuffer.isRecycled()) {
        bitmapBuffer.recycle();
        bitmapBuffer = null;
        System.gc();
    }
}

@amlcurran
Copy link
Owner

Merged a PR which should address this - #204 - so that will appear in the 5.1.0 snapshots now available

@swatijiet
Copy link

I am still getting this error. I have latest version 5.4.1 but i still get the same error.

@amlcurran
Copy link
Owner

@swatijet can you please post more details about how you're using
ShowcaseView?
On Mon, 7 Mar 2016 at 06:55, swatijiet notifications@github.com wrote:

I am still getting this error. I have latest version 5.4.1 but i still get
the same error.


Reply to this email directly or view it on GitHub
#183 (comment)
.

@swatijiet
Copy link

I am using two instances of showcaseview in my 2 activities. One of my activities have 2 fragments. I am only getting error on samsung devices where the bitmap created is very big.
In my activity where i have fragments, I am making an instance of showcaseview in main activity and then using same instance in the fragments:

This is the order of call :- Fragment 1 --> Child Fragment --> to main activity. At the end of each call , i call showcaseview.hide(). This all works fine but when i move to another activity after hide() is called in main activity, I get the crash. In another activity, i have about 9 targets to show, but error comes as soon as the first target is loaded.

@thilook
Copy link

thilook commented Mar 10, 2016

i am still getting this error but only in the Galaxy S4 and Galaxy s5 devices.

@amlcurran
Copy link
Owner

Hmmm I wonder if Samsung is leaking memory somewhere. I have a Samsung device at work and will try to reproduce this

@swatijiet
Copy link

@amlcurran any update on the error?

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

No branches or pull requests

7 participants