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

OutOfMemoryException #28

Open
spiritinlife opened this issue Jun 5, 2014 · 6 comments
Open

OutOfMemoryException #28

spiritinlife opened this issue Jun 5, 2014 · 6 comments

Comments

@spiritinlife
Copy link

I am playing around with your awesome lib and i came across this error.
OutOfMemory Exception ( I will try to add some logs )
What i am doing is that i get 5 icons from the camera folder and i pass them from the MainActivity to the Setup class as bitmaps.
After that i use this code to create MeshComponents
MeshComponent imageMesh = GLFactory.getInstance().newTexturedSquare(
"icon" + scounter, bitmap);

I get this error when trying to load the second image.
I have overcame this error by commenting out that line
texture = TextureManager.getInstance().resizeBitmapIfNecessary(texture);
which is at gl.textures.textureShape. textureShape constructor.
It seems to me that it always tries to recreate the bitmap resulting in OutOfMemory error.

@simon-heinen
Copy link
Owner

Hm normally the resizeBitmapIfNecessary is needed if the textures do not have a size with power of two so e.g. 256x128, so just leaving this method call away might cause crashes on some devices which can only handle such textures (actually I thought all devices can only handle such textures). Maybe you try to call a manual garbage collect after you loaded each image instead? but normally loading 5 images should not be a problem at all, only if you have very big images

@spiritinlife
Copy link
Author

-Maybe you try to call a manual garbage collect after you loaded each image instead?
--When i decode my images Path to a Bitmap i use the BitmapMarker Options to tell the GC that i you want more memory, the bitmap can be released.I did that because my activity would crach with OutOfMemoryException before even getting to the setup class.The mighty nexus 4 :) could not handle loading into memory 3-4 images.So that GC may be the problem.

-but normally loading 5 images should not be a problem at all, only if you have very big image.
--Do you think i can push that limit somehow ?

@simon-heinen
Copy link
Owner

wath resolution are these images? did you enable the large heap flag in your android manifest? that could help.

@spiritinlife
Copy link
Author

It seems like this large heap flag helped a lot thx.
I don't have much time these days to test it further.I will come back with more details when i have time.
Thank you for your helpful responses.

@simon-heinen
Copy link
Owner

That this flag helped also indicates that you are using to big images ;-)
did you check the resolution? I wouldn't use something bigger than
1200x1200 , in the ar world they will not be smaller just because you
reduce the resolution
Am 05.06.2014 23:06 schrieb "George Chailazopoulos" <
[email protected]>:

It seems like this large heap flag helped a lot thx.
I don't have much time these days to test it further.I will come back with
more details when i have time.
Thank you for your helpful responses.


Reply to this email directly or view it on GitHub
https://github.com/bitstars/droidar/issues/28#issuecomment-45274915.

@spiritinlife
Copy link
Author

Well the images come from the camera folder ,so the purpose of the app is to handle all images that have been taken using the phones camera.
So my guess is that the resolution of the image will be changing from device to device and it will be dependent to the camera(but i am no expert :) ) .Anyway i will check in what resolution*how many images i get this error with nexus 4 and i will come back again.

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

No branches or pull requests

2 participants