简体   繁体   English

Android-三星Galaxy S3图像加载

[英]Android - Samsung Galaxy S3 image loading

I have an android app that is working perfectly fine on almost all the Android devices. 我有一个几乎在所有Android设备上都能正常运行的android应用。 Recently, I tested this app on Samsung Galaxy S3 and it started crashing on me - it runs out of memory every now and then randomly. 最近,我在三星Galaxy S3上测试了该应用程序,它开始崩溃了,它偶尔会耗尽内存。

When the app loads up, it loads a splash image and a background image (about 100k in size). 应用加载后,会加载启动图像和背景图像(大小约为10万)。 When I remove these images from while the app is loading, the app works fine. 当我在加载应用程序时从其中删除这些图像时,该应用程序运行正常。 But when I leave them there, it runs out of memory randomly after the app loads up. 但是,当我将它们留在那里时,应用程序加载后它会随机耗尽内存。 I checked the resource directory and the app only has images in the Drawable folder, not in any of the drawable-hdpi or ldpi or mdpi folders. 我检查了资源目录,应用程序仅在Drawable文件夹中有图像,而在drawable-hdpi或ldpi或mdpi文件夹中都没有图像。 So is the device trying to convert these images to fit the phone's resolution and it's using all the memory? 那么,设备是否要尝试转换这些图像以适合手机的分辨率,并且正在使用所有内存? Do we have standard image sizes for hdpi, ldpi and mdpi folders? hdpi,ldpi和mdpi文件夹是否有标准图像尺寸? Any help will be greatly appreciated. 任何帮助将不胜感激。

The reason my app failed on Galaxy S3 is because Galaxy S3 has a much higher resolution than any other phones I tested my app with. 我的应用程序在Galaxy S3上失败的原因是因为Galaxy S3的分辨率比我测试过我的应用程序的任何其他手机都要高。 Hence the memory it allocated for the bitmaps was much higher and that caused the app to crash as it ran out of memory. 因此,它为位图分配的内存要高得多,并且导致该应用程序在内存不足时崩溃。 To solve the issue, I simple removed the bitmaps from the view in the onDestroy method and it solved the issue. 为了解决该问题,我简单地从onDestroy方法中的视图中删除了位图,从而解决了该问题。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM