简体   繁体   English

如何在Android中以编程方式增加RAM使用率?

[英]How to increase RAM usage programmatically in Android?

I need to increase RAM usage in Android programmatically to observe it changes in time. 我需要以编程方式增加Android中的RAM使用量,以便及时观察它的变化。 How can i do this? 我怎样才能做到这一点?

I tried to generate a lot of custom objects, but unexpectedly RAM usage decreases after generating it... I changed objects quantity, structure etc and nothing helps me. 我试图生成很多自定义对象,但是在生成它之后意外地降低了RAM的使用量......我改变了对象的数量,结构等,没有什么能帮助我。

I watch RAM usage in Android Profiler. 我在Android Profiler中观察RAM使用情况。

  • You can load images with higher resolution with big sizes. 您可以加载大尺寸更高分辨率的图像。 It's guaranteed to increase RAM usage which you can inspect using Android Profiler 保证增加RAM使用率,您可以使用Android Profiler进行检查
  • Use Custom Font in your app via libraries, like Calligraphy . 通过图书馆(如书法)在您的应用中使用自定义字体。 It should result in app memory increase. 它应该会导致应用内存增加。 The more additional Typefaces you use, the more memory it will start consuming, as stated in this closed issue of that library. 您使用的字体越多,它开始消耗的内存就越多,如该库的封闭式问题所述。
  • As the documentation says about how memory is counted, the Native memory from objects allocated from C or C++ code takes up a lot of memory. 正如文档中说明了如何计算内存,从C或C ++代码分配的对象的本内存占用了大量内存。 As TypeFace are allocated in Native memory and it makes Native heap size large, hence RAM usage gets increased a lot. 由于TypeFace在Native内存中分配,并且它使Native堆大小变大,因此RAM使用量增加了很多。 Refer to this answer to an inquiry on why an app takes up more memory for exploring the reason. 请参阅此答案 ,了解为什么应用占用更多内存以探索原因。
  • Add ByteArrayInputStream and allocate MAX sizes. 添加ByteArrayInputStream并分配MAX大小。 It will keep the memory as long as it's not destroyed. 只要它没有被破坏,它就会保留记忆。

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

相关问题 如何以编程方式增加RAM内存使用量? - How to increase the RAM Memory usage programatically? Android-为什么片段替换后RAM使用率继续增加? - Android - Why RAM usage continues to increase after fragment replace? 如何在android中获取应用程序的实际RAM使用情况? - How to get actual RAM usage of app in android? 为什么Android应用RAM使用量会永远稳定增加? 甚至Hello World应用程序 - Why does Android app RAM usage increase steadly forever? even Hello World app 在Java中以编程方式增加CPU使用率和内存使用率 - Programmatically increase the CPU usage and memory usage in java 如何以编程方式增加Android中的文本数量 - How to increase the number of text in Android programmatically 以编程方式以受控方式增加 CPU 使用率 - Increase CPU Usage in a controlled manner programmatically 在Android上获取CPU,RAM和网络使用情况统计信息 - Get cpu, ram and network usage statistics on Android Android Studio 生成多个 java 进程! 如何在低内存机器上最小化其内存使用量? - Android Studio spawning multiple java processes! How to minimize its memory usage on a low-ram machine? 如何限制Java进程RAM的使用 - how to limit java process RAM usage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM