当前位置:网站首页>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
边栏推荐
- Shell 未知汇总1
- konva系列教程3:自定义图形
- Operations research note
- Analyzing the practical development of robot teaching
- Unity about oculus quest2 basic development based on XR interaction toolkit 003- capture function - making a VR bowling game
- Database Experiment 7 integrity constraints
- 推荐两款超高质量的壁纸软件
- Konva series tutorial 3: Customizing drawings
- EasyCVR新建用户后,视频调阅页面不能点击的问题修复
- id门禁卡复制到手机_怎么把手机变成门禁卡 手机NFC复制门禁卡图文教程
猜你喜欢

闭包的理解

被315点名的流氓下载器,又回来了…

抗兔Dylight 488丨Abbkine通用型免疫荧光(IF)工具箱

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

内存泄露

微信小程序接入百度统计报错 Cannot read property ‘mtj‘ of undefined

Yixin Huachen: real estate enterprises want to grasp the opportunity of the times for digital transformation

Unity about oculus quest2 developing 002-ui interaction based on XR interaction Toolkit

Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known

向上转型和向下转型
随机推荐
Apifox 介绍
Three communication skills in software testing
Chapter 2 processing files, cameras and GUI Cameo applications
Openfire用户以及群组关系移植
实时Transformer:美团在单图像深度估计上的研究
第2章 处理文件、摄像头和图形用户界面cameo应用
内存抖动
About Statistical Distributions
How to manage interface documents efficiently and gracefully
BioVendor游离轻链(κ和λ)Elisa 试剂盒检测步骤
sqrt()函数的详解和用法「建议收藏」
Go, begin, end, for, after, instead of
今天开户今天能买股票吗?在线开户是安全么?
安装nodejs环境
golang中的select详解(转)
C语言指针的一些易错点
HackTheBox-baby CachedView
【云驻共创】昇腾异构计算架构CANN,助力释放硬件澎湃算力
中金财富开户安全吗?开过中金财富的讲一下
Cann media data processing V2, jpegd interface introduction