On-Disk Storage Management
Data storage management is essential for preventing unnecessary resource usage, which affects not only performance but also battery life and overall end-user experience.
Implementing a well-thought data storage strategy can ensure that your app remain memory-efficient, resulting in faster load times, improved battery life, and a more responsive UI.
However, failing to carefully plan your memory usage strategy can lead to significant risks, including memory leaks, performance degradation, crashes, data loss, and reduced battery life.
Depending on your use case, use the EVICT API method to remove data, as well as applying soft-delete patterns to implement tools to help optimize memory usage in your app.
When planning your approach to memory management in your app, use the following recommended practices to help you during the decision-making process:
Consideration | Recommendation |
Sync subscriptions | When subscribing to and evicting data, maintain a balanced approach. Keep in mind that before invoking the EVICT method, you must first cancel relevant subscriptions and restart them afterward — resulting in increases in network usage, which can degrade sync performance. |
Access frequency and relevance | Set up an automatic process that evicts documents accessed less frequently or no longer relevant on a regular basis, but no more than once per day during periods of minimal disruption, such as after hours and at night. |
Time-based data | Establish an automatic process to remove time‑based data older than a minimum of seven days. (Until expired, time‑based data remains accessible by way of local queries.) |
Permanent data loss | Before using the EVICT method to delete messages, carefully evaluate your specific use case and consider opting for alternatives:
|