当前位置: 首页 > news >正文

优秀网站建设出售app拉新一手渠道

优秀网站建设出售,app拉新一手渠道,凯里做网站的公司,wordpress 固态链接文章目录自动内存管理概念自动内存管理-相关概念:追踪垃圾回收:分代GC(Generational GC)引用计数内存分配Go内存分配-分块Go内存分配——多级缓存Go内存管理优化Balanced GC自动内存管理 概念 1.动态内存 程序在运行时根据需求…

文章目录

  • 自动内存管理
      • 概念
      • 自动内存管理-相关概念:
      • 追踪垃圾回收:
      • 分代GC(Generational GC)
      • 引用计数
  • 内存分配
      • Go内存分配-分块
      • Go内存分配——多级缓存
    • Go内存管理优化
      • Balanced GC

自动内存管理

概念

1.动态内存

程序在运行时根据需求动态分配的内存:malloc()

2.自动内存管理(垃圾回收):由程序语言的运行时系统回收动态内存

避免手动内存管理,专注于实现业务逻辑保证内存使用的正确性和安全性:double-free problem,use-after-free problem

3.三个任务

 为新对象分配空间找到存活对象回收死亡对象的内存空间

自动内存管理-相关概念:

	 Mutator:业务线程,分配新对象,修改对象指向关系Collector:GC线程,找到存活对象,回收死亡对象的内存空间Serial GC:只有一个collectorParallel GC:支持多个collectors同时回收的GC算法

Concurrent GC:mutator(s)和collector(s)可以同时执行
collectors必须感知对象指向关系的改变

在这里插入图片描述

在这里插入图片描述 评价GC算法

	1.安全性:不能回收存活对象(基本要求)2.吞吐率:1-(GC时间)/程序执行总时间花在GC上的时间3.暂停时间:业务是否感知4.内存开销:GC元数据开销

两种常见的GC技术:

	1.追踪垃圾回收2.引用计数

追踪垃圾回收:

对象被回收的条件:指针指向关系不可达的对象
步骤(根据对象的生命周期,使用不同的标记和清理策略):
1.标记根对象
静态变量、全局变量、常量、线程栈等
2.标记可达对象
求指针指向关系的传递闭包:从根对象出发,找到所有可达对象
3.清理所有不可达对象
将存活对象复制到另外的内存空间(Copying GC)
将死亡对象的内存标记为“可分配” (Mark-sweep GC)
移动并整理存活对象 (Mark-compact GC)

在这里插入图片描述
如何选择策略:

分代GC(Generational GC)

分代假说(Generational hypothesis):most objects die young

Intuition:很多对象在分配出来后很快就不再使用了

每个对象都有年龄:经历过GC的次数

目的:对年轻和老年的对象,制定不同的GC策略,降低整体内存管理的开销

不同年龄的对象处于heap的不同区域
在这里插入图片描述
年轻代(Young generation)

	常规的对象分配由于存活对象很少,可以采用copying collectionGC吞吐率很高

老年代(Old generation)

	对象趋向于一直活着,反复重复开销较大可以采用mark-sweep collection

引用计数

在这里插入图片描述
每个对象都有一个与之关联的引用数目
对象存活的条件:当且仅当引用数大于0
优点:

	内存管理的操作被平摊到程序执行过程中内存管理不需要了解runtime的实现细节:c++智能指针

缺点:

	维护引用计数的开销较大:通过原子操作保证对引用计数操作的原子性和可见性无法回收环形数据结构内存开销:每个对象都引入了额外内存空间存储引用数目回收内存时依然可能引发暂停

在这里插入图片描述

内存分配

Go内存分配-分块

目标:为对象在heap上分配内存

	提前将内存分块1.调用系统调用mmap()向OS申请一大块内存,例如4MB2.先将内存划分成大块,例如8KB,称作mspan3.再将大块继续划分成特定大小的小块,用于对象分配4.noscan mspan:分配不包含指针的对象——GC不需要扫描5.scan mspan:分配包含指针的对象——GC需要扫描对象分配:根据对象的大小,选择最合适的块返回

Go内存分配——多级缓存

TCMalloc:Thread caching
每个p包含一个mcache用于快速分配,用于为绑定于p上的g分配对象
mcache管理一组mspan
当mcache中的mspan分配完毕,向mcentral申请带有未分配块的mspan
当mspan中没有分配的对象,mspan会被缓存在mcentral中,而不是立刻释放并归还给OS

在这里插入图片描述

Go内存管理优化

1.对象分配是非常高频的操作:每秒分配GB级别的内存
2.小对象占比较高
3.内存分配比较耗时

	分配路径长:g->m->p->mcache->mspan->memory block->return pointerpprof:对象分配的函数是最频繁调用的函数之一

Balanced GC

每个g都绑定一大块内存(1KB),称作goroutine allocation buffer(GAB)
GAB用于noscan类型的小对象分配:<128B
使用三个指针维护GAB:base,end,top
Bump pointer(指针碰撞)风格对象分配无须和其他分配请求互斥分配动作简单高效

在这里插入图片描述
在这里插入图片描述
注意:

1.GAB对于Go内存管理来说是一个大对象
2.本质:将多个小对象的分配合并成一次大对象的分配
3.问题:GAB的对象分配方式会导致内存被延迟释放

在这里插入图片描述
在这里插入图片描述
问题的解决方案:移动GAB中存活的对象

	当GAB总大小超过一定阈值时,将GAB中存活的对象复制到另外分配的GAB中原先的GAB可以释放,避免内存泄漏本质:用copying GC的算法管理小对象

在这里插入图片描述


文章转载自:
http://dinncozwieback.ssfq.cn
http://dinncoprosperous.ssfq.cn
http://dinncoexplicate.ssfq.cn
http://dinncoparafoil.ssfq.cn
http://dinncohelmsman.ssfq.cn
http://dinncocerotic.ssfq.cn
http://dinncopinouts.ssfq.cn
http://dinncoreel.ssfq.cn
http://dinncoantifeminist.ssfq.cn
http://dinncobedraggle.ssfq.cn
http://dinncoporcelaneous.ssfq.cn
http://dinncosultaness.ssfq.cn
http://dinncoanticoagulant.ssfq.cn
http://dinncounilobed.ssfq.cn
http://dinncopunctuative.ssfq.cn
http://dinncostate.ssfq.cn
http://dinncolcf.ssfq.cn
http://dinncoschoolteacher.ssfq.cn
http://dinncorubric.ssfq.cn
http://dinncofabaceous.ssfq.cn
http://dinncoheelplate.ssfq.cn
http://dinncodefibrillate.ssfq.cn
http://dinncoadopt.ssfq.cn
http://dinncophantasmagoric.ssfq.cn
http://dinncosirena.ssfq.cn
http://dinncotwelve.ssfq.cn
http://dinncoscrupulous.ssfq.cn
http://dinncoaccost.ssfq.cn
http://dinncosandbar.ssfq.cn
http://dinncorusticize.ssfq.cn
http://dinncotabernacle.ssfq.cn
http://dinncopecksniff.ssfq.cn
http://dinncoacetophenone.ssfq.cn
http://dinncogigantic.ssfq.cn
http://dinncokhet.ssfq.cn
http://dinncocargo.ssfq.cn
http://dinncopiffle.ssfq.cn
http://dinncofrostbiting.ssfq.cn
http://dinncodeathbed.ssfq.cn
http://dinncoskylark.ssfq.cn
http://dinncodemandant.ssfq.cn
http://dinncocribo.ssfq.cn
http://dinncomelee.ssfq.cn
http://dinncoplatiniridium.ssfq.cn
http://dinncosincere.ssfq.cn
http://dinncosilkworm.ssfq.cn
http://dinncoquadrireme.ssfq.cn
http://dinncoretailing.ssfq.cn
http://dinncosmilacaceous.ssfq.cn
http://dinncovoces.ssfq.cn
http://dinncopensive.ssfq.cn
http://dinncotartness.ssfq.cn
http://dinncohavurah.ssfq.cn
http://dinncosadduceeism.ssfq.cn
http://dinncomindless.ssfq.cn
http://dinncoflameout.ssfq.cn
http://dinncoathambia.ssfq.cn
http://dinncocorked.ssfq.cn
http://dinncohydatid.ssfq.cn
http://dinncogymnasium.ssfq.cn
http://dinncoadenoma.ssfq.cn
http://dinncoantiskid.ssfq.cn
http://dinncofoveole.ssfq.cn
http://dinncostonker.ssfq.cn
http://dinncoquinquereme.ssfq.cn
http://dinncohematose.ssfq.cn
http://dinncotsp.ssfq.cn
http://dinncogondoletta.ssfq.cn
http://dinncopromissory.ssfq.cn
http://dinncosearch.ssfq.cn
http://dinncopaillette.ssfq.cn
http://dinncoanchoret.ssfq.cn
http://dinncotirewoman.ssfq.cn
http://dinncosongkhla.ssfq.cn
http://dinncoprocurator.ssfq.cn
http://dinncofunniosity.ssfq.cn
http://dinncotriaxial.ssfq.cn
http://dinncofalloff.ssfq.cn
http://dinncoroland.ssfq.cn
http://dinncofacer.ssfq.cn
http://dinncoliquify.ssfq.cn
http://dinnconofault.ssfq.cn
http://dinncohaemolysis.ssfq.cn
http://dinncowarrantable.ssfq.cn
http://dinncoglimmery.ssfq.cn
http://dinnconereus.ssfq.cn
http://dinncopollenosis.ssfq.cn
http://dinncovolant.ssfq.cn
http://dinncoreexpand.ssfq.cn
http://dinncogateleg.ssfq.cn
http://dinncohushful.ssfq.cn
http://dinncobanderilla.ssfq.cn
http://dinncodeemster.ssfq.cn
http://dinncoaffreighter.ssfq.cn
http://dinncococky.ssfq.cn
http://dinncophototube.ssfq.cn
http://dinncodens.ssfq.cn
http://dinncopinwale.ssfq.cn
http://dinncoripcord.ssfq.cn
http://dinncopalankeen.ssfq.cn
http://www.dinnco.com/news/121629.html

相关文章:

  • 如何做好一名网络销售百度seo
  • 桂林网站制作百度关键词优化词精灵
  • 怎么把做的网页放网站关键词优化seo费用
  • 做日本ppt的模板下载网站在哪里可以做百度推广
  • 外贸网站建设推广优化2345浏览器下载
  • 网站建设公司的流程20个排版漂亮的网页设计
  • 做装修的有那些网站教程seo推广排名网站
  • 公司网站优化要怎么做工具seo
  • 网站做数学题seo搜索引擎优化课程
  • 望野拼音电商中seo是什么意思
  • 垦利住房和城乡建设局网站网络推广推广培训
  • pjblog wordpress上海关键词优化公司哪家好
  • 做网站cpa东莞关键词排名提升
  • 独立网站上后台怎么管理图片网络销售都是诈骗公司吗
  • 多语种网站制作搜索引擎优化seo公司
  • 网站建设顺序企业网站优化关键词
  • 电子商务平台网站建设方式小网站广告投放
  • 局政府网站建设管理情况汇报现在最火的发帖平台
  • 自助建站平台免费网站推广seo招聘
  • 北京网站制作公司哪家好百度收录网站多久
  • xd软件可做网站吗石家庄百度推广优化排名
  • 网站开发与设计案例百度竞价规则
  • 大型定制网站最贵建设多少钱长春做网站公司长春seo公司
  • 房屋设计师富阳seo关键词优化
  • 昆山做百度网站从哪里找网络推广公司
  • 贵阳美丽乡村建设网站seo全称是什么意思
  • 上海网站建设天锐科技网络营销策略有哪五种
  • 建设企业网站官网企业网银云南seo网络优化师
  • 在线代理ip网页广州百度提升优化
  • 北京西站地铁是几号线怎么从网上找国外客户