当前位置:网站首页>memory thrashing
memory thrashing
2022-06-28 18:42:00 【Novice Xiaowang】
One . Memory jitter
1. Memory jitter : It refers to the phenomenon that a large number of objects are created or recycled in a short time .
2. Causes of memory jitter : Mainly frequent ( Very important ) Create objects in loops ( A large number of objects are created in a short time , Because new objects occupy memory space and are frequent , If you create an object in a loop once or twice, it has little effect on memory , It will not cause serious memory jitter, which is acceptable and inevitable , Frequently, the memory jitter is very serious ), The effect of memory jitter is if the jitter is frequent , Will cause the garbage collection mechanism to run frequently ( Generate a large number of objects in a short time , Need a lot of memory , And still shake frequently , You may need to reclaim memory for generating objects , The garbage collection mechanism will naturally run frequently ).
3. Memory jitter affects : Frequent memory jitter can cause garbage collection to run frequently , Cause the system to jam .
Solution
Where are the common memory jitters ?
1.Android Of onDraw, onMeasure Method .
here , The authorities do not recommend creating objects here , Why? ? I see , It is frequently called by the bottom layer ,( You can learn about the Android refresh mechanism ), If you create a large number of objects , Frequent recycling , Memory jitter is easy . If it is bitmap, His memory is in native The distribution of , Processing needs to go through the kernel , Make the waiting time longer .
2. Handle io The place of
Read and write files , The memory stream creates a large number of byte[] The object will appear .
3. Produce components of the consumer model , These frequently produce a large number of objects , Like logs , Embedded point components, etc
4. Complex type json analysis .
such as Gson. By default , Is to generate new instances through reflection . Using the object pool through the adapter can solve
Recommend solutions :
adopt Reuse objects Use to solve memory jitter ,
For example, enjoy yuan design pattern , Object pool scheme . But object pooling does not reduce memory , You need to limit the memory , And each object scene is different , You may need to filter . need lru Data structure of the algorithm, etc . May refer to handler,glide Object pool principle .
The principle of object pooling is simple , It is to create objects and store them in memory after use , For example, save it in the linked list , The next time you use an object , Look it up in the linked list first , If there is, take it out , If not, create , This avoids the creation of a large number of objects
边栏推荐
- 杂记:数据库go,begin,end,for,after,instead of
- February 15, 2022 learning summary
- 数据资产为王,如何解析企业数字化转型与数据资产管理的关系?
- 做跨境电商一定要学会用PRA软件,解放双手提高效率!
- Openfire 3.8.2集群配置
- 正版ST-link/V2 J-LINK JTAG/SWD引脚定义和注意事项
- An error is reported when ActiveMQ is started. The 1883 port occupation problem is solved
- 微软独家付费功能,也被完美解锁了
- ANR Application Not Responding
- Lumiprobe非荧光叠丨氮化物研究丨3-叠丨氮丙醇
猜你喜欢

Graphic system - 1 Layout loading

Mycat+分库分表

Lumiprobe丨Lumizol RNA 提取试剂解决方案

Seata implementation of sharing JDBC distributed transaction

如何设计业务高性能高可用计算架构 - 作业

618活动季——百数低代码平台特享折扣来临

匿名函数变量问题

SMARCA2抗体研究:Abnova SMARCA2 单克隆抗体方案

POI Excel转换工具

Applet graduation design based on wechat beauty salon technician appointment applet graduation design opening report function reference
随机推荐
杂记:数据库go,begin,end,for,after,instead of
render函数解析
CANN媒体数据处理V2,JPEGD接口介绍
curl: (56) Recv failure: Connection reset by peer
BioVendor游离轻链(κ和λ)Elisa 试剂盒检测步骤
【Unity3D】发射(RayCast)物理射线(Ray)
1 invalid import format(s) Postman Collection Format v1 is no longer supported and can not be import
use. NETCORE's own background job, which simply simulates producers and consumers' processing of request response data in and out of the queue
C语言文件操作
devpi
Analysis of response parsing process of SAP ui5 batch request
Shell 未知汇总1
io模型初探
Can I open an account today and buy shares today? Is it safe to open an account online?
华为云AOM发布2.0版本,3大特性亮相
Lumiprobe 蛋白质标记研究方案
双功能交联剂丨Lumiprobe 磺基花青7二羧酸研究
软件测试的三个沟通技巧
手动备份和还原DHCP服务器
How to design a business high performance and high availability computing architecture - job