A antonomase Active Member Licensed User Longtime User Dec 1, 2013 #1 Hi, One of my users send me the following error when he use my application. I do not have this error on my tablet. How can I know where the error come from ? I have an idea : the application uses 5 panels wich fill all the screen : the user can switch from one to another one by buttons. One of these panels uses a lot of bitmaps. It has no interaction with the other panels How can I replace something like Code: Copy pnl1.Visible = false pnlBitmap.Visible = true by open the panel in an other process ? Attachments Screenshot_2013-12-01-20-56-33.png 41.6 KB · Views: 414
Hi, One of my users send me the following error when he use my application. I do not have this error on my tablet. How can I know where the error come from ? I have an idea : the application uses 5 panels wich fill all the screen : the user can switch from one to another one by buttons. One of these panels uses a lot of bitmaps. It has no interaction with the other panels How can I replace something like Code: Copy pnl1.Visible = false pnlBitmap.Visible = true by open the panel in an other process ?
Erel B4X founder Staff member Licensed User Longtime User Dec 2, 2013 #2 Are you loading the bitmaps with LoadBitmapSample? Upvote 0
A antonomase Active Member Licensed User Longtime User Dec 2, 2013 #3 No. I will try it. But bitmaps are jpeg files about 40-50 Kb. Can the problem occurs if these files are larger than the screen ? Upvote 0
No. I will try it. But bitmaps are jpeg files about 40-50 Kb. Can the problem occurs if these files are larger than the screen ?
Erel B4X founder Staff member Licensed User Longtime User Dec 2, 2013 #4 The compressed size doesn't matter. Only the image dimensions. Upvote 0
A antonomase Active Member Licensed User Longtime User Dec 2, 2013 #5 The larger image is 1280x800. Even on a tablet 7", it is not a very large image. I'm not sure that the problem comes from these images. But with such an error message (Bitmap outofMemory, line -2) it is difficult to test and debug. Upvote 0
The larger image is 1280x800. Even on a tablet 7", it is not a very large image. I'm not sure that the problem comes from these images. But with such an error message (Bitmap outofMemory, line -2) it is difficult to test and debug.
Erel B4X founder Staff member Licensed User Longtime User Dec 2, 2013 #6 You should post the full error message. Run it in Debug mode. Upvote 0
A antonomase Active Member Licensed User Longtime User Dec 2, 2013 #7 I can't : the application run fine on my tablet. It's an hardcopy sended by an user. Upvote 0
eps Expert Licensed User Longtime User Dec 2, 2013 #8 antonomase said: I can't : the application run fine on my tablet. It's an hardcopy sended by an user. Click to expand... Is it on a Samsung device? Upvote 0
antonomase said: I can't : the application run fine on my tablet. It's an hardcopy sended by an user. Click to expand... Is it on a Samsung device?
A antonomase Active Member Licensed User Longtime User Dec 2, 2013 #9 yes. Samsung galaxy Tab 7 GT-P3110 with Android 4.1.2. Why ? Upvote 0
Informatix Expert Licensed User Longtime User Dec 2, 2013 #10 What's the memory consumption of your app (use any free tool available on Google Play to get an idea or, better, use the Monitor tool provided with the SDK)? What's exactly the memory taken by your images (you can compute this with the formula width*height*4)? What's the maximum Java heap size of the user's device? With these 3 numbers, you should have a strong hint. Upvote 0
What's the memory consumption of your app (use any free tool available on Google Play to get an idea or, better, use the Monitor tool provided with the SDK)? What's exactly the memory taken by your images (you can compute this with the formula width*height*4)? What's the maximum Java heap size of the user's device? With these 3 numbers, you should have a strong hint.
A antonomase Active Member Licensed User Longtime User Dec 2, 2013 #11 The memory used by the application is from 110 to 190 Mb. I use 1 image for the splash screen : 1000x625 for tablets 10" and 800x500 for the tablets 7" 7 icons file png : 5 in 64x64, 1 in 40x40 and 1 in 32x32 1 image png : 256 x 256 There is a slideshow in the application : the default files are 1 file 1280x800 and 1 file 512x597. They are loaded one by one. Plus the clsWheel (One time, i had a problem of memory with it. But just one time) The biggest file is a background image 1760x2414 which is resized. I will try to resample it. I don't know how to get the Java heap size. Upvote 0
The memory used by the application is from 110 to 190 Mb. I use 1 image for the splash screen : 1000x625 for tablets 10" and 800x500 for the tablets 7" 7 icons file png : 5 in 64x64, 1 in 40x40 and 1 in 32x32 1 image png : 256 x 256 There is a slideshow in the application : the default files are 1 file 1280x800 and 1 file 512x597. They are loaded one by one. Plus the clsWheel (One time, i had a problem of memory with it. But just one time) The biggest file is a background image 1760x2414 which is resized. I will try to resample it. I don't know how to get the Java heap size.
Informatix Expert Licensed User Longtime User Dec 3, 2013 #12 antonomase said: The memory used by the application is from 110 to 190 Mb. Click to expand... Unless you set LargeHeap to true in your manifest, that's too much for most devices. And even LargeHeap is not the ultimate solution because this setting is ignored before Honeycomb and some devices (I have one in this case) won't allocate more than 128 MB to the large heap (especially if their total RAM is 256 Mb or less). So you should try to reduce your memory consumption under 128 MB if your application is not designed for a specific device. antonomase said: I use 1 image for the splash screen : 1000x625 for tablets 10" and 800x500 for the tablets 7" 7 icons file png : 5 in 64x64, 1 in 40x40 and 1 in 32x32 1 image png : 256 x 256 There is a slideshow in the application : the default files are 1 file 1280x800 and 1 file 512x597. They are loaded one by one. Click to expand... I think the main culprit is your slideshow. You probably do not remove the images from memory once they are seen, so the memory usage grows with each new image. I cannot give more details without knowing how you display and handle your images. antonomase said: The biggest file is a background image 1760x2414 which is resized. I will try to resample it. Click to expand... Resampling is not enough, you have to rescale it. You can use the LoadScaledBitmap function of my BetterImageView lib. FYI, this image alone consumes 16 MB of RAM. antonomase said: I don't know how to get the Java heap size. Click to expand... You just have to know what the device is. The max VM heap size is publicly available in the specs. Otherwise, you can use my Cache lib or my StrictMode lib to know the max. available memory when you start your app. Upvote 0
antonomase said: The memory used by the application is from 110 to 190 Mb. Click to expand... Unless you set LargeHeap to true in your manifest, that's too much for most devices. And even LargeHeap is not the ultimate solution because this setting is ignored before Honeycomb and some devices (I have one in this case) won't allocate more than 128 MB to the large heap (especially if their total RAM is 256 Mb or less). So you should try to reduce your memory consumption under 128 MB if your application is not designed for a specific device. antonomase said: I use 1 image for the splash screen : 1000x625 for tablets 10" and 800x500 for the tablets 7" 7 icons file png : 5 in 64x64, 1 in 40x40 and 1 in 32x32 1 image png : 256 x 256 There is a slideshow in the application : the default files are 1 file 1280x800 and 1 file 512x597. They are loaded one by one. Click to expand... I think the main culprit is your slideshow. You probably do not remove the images from memory once they are seen, so the memory usage grows with each new image. I cannot give more details without knowing how you display and handle your images. antonomase said: The biggest file is a background image 1760x2414 which is resized. I will try to resample it. Click to expand... Resampling is not enough, you have to rescale it. You can use the LoadScaledBitmap function of my BetterImageView lib. FYI, this image alone consumes 16 MB of RAM. antonomase said: I don't know how to get the Java heap size. Click to expand... You just have to know what the device is. The max VM heap size is publicly available in the specs. Otherwise, you can use my Cache lib or my StrictMode lib to know the max. available memory when you start your app.
A antonomase Active Member Licensed User Longtime User Dec 3, 2013 #13 So you should try to reduce your memory consumption under 128 MB if your application is not designed for a specific device. Click to expand... I'm OK : the application use a lot of memory. I will move all the large pictures currently into the application to the disk and load them when needed. But it will be a problem if the user erases some of these files. Question : If a file is loaded into an imageview (imageview.bitmap = loadBitmap (...)), is it possible to restore memory space with imageview.bitmap = null after use ? Upvote 0
So you should try to reduce your memory consumption under 128 MB if your application is not designed for a specific device. Click to expand... I'm OK : the application use a lot of memory. I will move all the large pictures currently into the application to the disk and load them when needed. But it will be a problem if the user erases some of these files. Question : If a file is loaded into an imageview (imageview.bitmap = loadBitmap (...)), is it possible to restore memory space with imageview.bitmap = null after use ?
Informatix Expert Licensed User Longtime User Dec 3, 2013 #14 antonomase said: Question : If a file is loaded into an imageview (imageview.bitmap = loadBitmap (...)), is it possible to restore memory space with imageview.bitmap = null after use ? Click to expand... You should load your bitmaps into the ImageView with LoadBitmapSample or, better, LoadScaledBitmap (with a BetterImageView). And to clear the memory, set Bitmap to null indeed. It's not immediate because the memory is cleared asynchronously by the garbage collector, but it's the proper way to do it. Upvote 0
antonomase said: Question : If a file is loaded into an imageview (imageview.bitmap = loadBitmap (...)), is it possible to restore memory space with imageview.bitmap = null after use ? Click to expand... You should load your bitmaps into the ImageView with LoadBitmapSample or, better, LoadScaledBitmap (with a BetterImageView). And to clear the memory, set Bitmap to null indeed. It's not immediate because the memory is cleared asynchronously by the garbage collector, but it's the proper way to do it.
A antonomase Active Member Licensed User Longtime User Dec 3, 2013 #15 Another question : to export files to the "disk", I do Code: Copy If File.Exists(File.DirDefaultExternal, "img1.png") = False Then File.Copy(File.DirAssets, "img1.png", File.DirDefaultExternal, "img1.png") End If So before to be in DirDefaultExternal, images are in DirAssets. Can this cause an OutOfMemory error ? Upvote 0
Another question : to export files to the "disk", I do Code: Copy If File.Exists(File.DirDefaultExternal, "img1.png") = False Then File.Copy(File.DirAssets, "img1.png", File.DirDefaultExternal, "img1.png") End If So before to be in DirDefaultExternal, images are in DirAssets. Can this cause an OutOfMemory error ?
Informatix Expert Licensed User Longtime User Dec 3, 2013 #16 antonomase said: Another question : to export files to the "disk", I do Code: Copy If File.Exists(File.DirDefaultExternal, "img1.png") = False Then File.Copy(File.DirAssets, "img1.png", File.DirDefaultExternal, "img1.png") End If So before to be in DirDefaultExternal, images are in DirAssets. Can this cause an OutOfMemory error ? Click to expand... I don't think so. I didn't look at the Copy source code but I would be very surprised if it does not use a stream (so its memory consumption is a few KB whatever the file size may be). Upvote 0
antonomase said: Another question : to export files to the "disk", I do Code: Copy If File.Exists(File.DirDefaultExternal, "img1.png") = False Then File.Copy(File.DirAssets, "img1.png", File.DirDefaultExternal, "img1.png") End If So before to be in DirDefaultExternal, images are in DirAssets. Can this cause an OutOfMemory error ? Click to expand... I don't think so. I didn't look at the Copy source code but I would be very surprised if it does not use a stream (so its memory consumption is a few KB whatever the file size may be).
A antonomase Active Member Licensed User Longtime User Dec 3, 2013 #17 Thanks. I will try all of this and I will see with that user if it has always problem. See you again in a few days. Upvote 0
Thanks. I will try all of this and I will see with that user if it has always problem. See you again in a few days.