简体   繁体   English

应用程序中使用的静态映像的内存不足异常

[英]Out of memory exception for static images used in application

Let's say i have 10 activities, and each contain a static image, I am finishing and starting a new activity on left and right click of the arrow. 假设我有10个活动,每个活动都包含一个静态图片,我正在按箭头的左键和右键单击完成并开始一个新的活动。 在此处输入图片说明

Images are in drawable folder and are a bit large size, As far as i think, if a activity finishes then all the memory it's using is freed(that's why i had taken so many activities), but it's not happening. 图像位于可绘制的文件夹中,并且有点大,据我认为,如果一个活动完成,那么它正在使用的所有内存都将被释放(这就是为什么我进行了如此多的活动),但是这没有发生。

If constantly go on clicking the right and left button, the app freezes and crashes(out of memory exception). 如果持续单击左右按钮,则该应用程序将冻结并崩溃(内存不足异常)。

Is there any way to avoid this? 有什么办法可以避免这种情况?

1- Load your images using: 1-使用以下方法加载图像:

BitmapFactory.decodeResource(res, id, opts);

Use inSampleSize in Options to rescale your image. 使用“ Options inSampleSize重新缩放图像。

2- Recycle your bitmap in onDestroy() . 2-在onDestroy()回收位图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 简单静态画廊的情况下,内存不足异常 - Out of memory exception in case of simple static gallery 具有图像和文本的Listview的内存不足异常 - Out of memory Exception on Listview with images and text Android应用程序内存不足,无法处理图像 - Android application out of memory without dealing with images 将大量图像加载到内存会导致内存不足异常-Android - Loading a lot of images to memory causes Out of memory exception - Android 将图像从sdcard加载到gridview中会抛出内存不足异常? - Loading images from sdcard into a gridview throwing Out of memory exception? RxAndroid 上传多张图片时出现内存不足异常 - RxAndroid getting Out of memory exception while uploading multiple images 在对图像应用过滤器时避免内存异常(Android) - Avoiding Out Of Memory Exception in applying filters to Images (Android) 具有许多图像的自定义ListView获得Out of Memory Exception - Custom ListView with many images gets Out Of Memory Exception 如何在内存不足异常情况下在Android应用程序中解压缩RAR文件? - How to decompress a RAR file in Android application with out of memory exception? android中的内存不足异常:应用程序为过去使用的屏幕重新分配了内存 - Out of memory Exception in android : app re-allocates memory for screens used in past
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM