How does the OutOfMemory happens?
How does the OutOfMemory happens?
Here is a detailed answer to the Android interview question "How does OutOfMemoryError happen?":
An OutOfMemoryError (OOM) occurs when the Android app tries to allocate more memory than is available to the app's process. This can happen for a few key reasons:
Bitmaps are a common cause of OOMs. Loading large bitmaps into memory without properly scaling or sampling them can easily exceed the available heap size. Bitmaps should be loaded and scaled to the exact size needed to avoid wasting memory.
If an Activity or View has a reference to a large object that is not properly cleared when the Activity or View is destroyed, it can cause a memory leak. This leads to the objects staying in memory longer than needed, eventually causing an OOM.
Using inefficient data structures like ArrayLists or HashMaps to store large amounts of data can lead to OOMs. Prefer using more ...
junior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào