简体   繁体   English

有关Android中内存问题的问题

[英]Question on Memory Issues in Android

如果我们在Android中使用大量逐帧动画,会不会出现内存问题

That depends entirely upon how you implement it, and details such as how large your frames are and what kind of color-depth you choose to use. 这完全取决于您如何实现它,以及细节,例如框架的大小以及选择使用哪种色深。 In general, however, you should be able to come up with a rendering algorithm that doesn't hold references to more than a handful of frames at any one point in time. 但是,总的来说,您应该能够提出一种渲染算法,该算法在任何一个时间点都不会保存对多个帧的引用。

Ideally you should only need a reference to the previous frame and your working buffer for the current frame. 理想情况下,您只需要引用前一帧和当前帧的工作缓冲区即可。 Assuming that's the case, and assuming that you're using 8-bit RGBA pixel encoding, then you can easily work out how approximately much memory your animation will consume when running. 假设是这种情况,并假设您使用的是8位RGBA像素编码,则可以轻松确定动画在运行时将消耗多少内存。 It's: 它的:

frame.width * frame.height * 4 * 2 bytes frame.width * frame.height * 4 * 2个字节

And then from that you can make a reasonable estimate of whether or not your device can meet your memory requirements. 然后,您可以据此合理估计设备是否可以满足内存要求。 As a general rule, as long as your frames are not larger than your device resolution you should be okay. 通常,只要您的帧不大于设备分辨率,就可以了。

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

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