今天又有个粉丝问我了, v v 二后端一次给 e l table 返回了一万条数据,前端卡着卡着就内存溢出了,这个怎么解决?像这个啊,这个问题, 他呢就不能用这个 eltable 了,这个性能很差的啊,一百条数据以内可以用这个,对吧?两三百条就开始卡了啊,五百条基本就用不了了。 好吧,那不用,他用什么用这个啊?用个 v s e table, 这个文档在这里啊,你马上搜一下就有了。然后这是他的一个官网,这是他的 deta 上面的一个地址啊,用六点五 k 星了, 它这里面呢,有两个,有两个表啊,一个虚拟往下滚动,有一个 e s e table 啊,用这个。如果是你是 一个 table 啊,那你就用它,如果你不是 table, 因为有的它不一定是列表啊,不是一定是列表,那你就用 greed 啊,这个也是可以的。这两个,但是他们有个坑啊,你们可以自己去踩一下。 嗯,再说一下他们有什么弊端吗?他们的弊端就是,嗯,在你比如说频繁更新数据的时候,他不太适合。什么叫频繁更新? 就比如说这个表里面他他有多个字段,比如说这个字段参数,这个字段他是 table, 对吧?那我要他是一个进度,从一到一百,对吧?我不断修改这个进度,那么啊,就相当有可能你需要修改整个表啊,比如说很多或者增加减少 这样的数据。很多啊,比如说很频繁的去增加减少,那么这个 v e s e table, 或者 说是这个 vs egree 的,可能不太适合,但是如果说你是后端返回你的数据直接展示的话,这个非常合适啊,可以这么说,当然除了这个还有吗?啊,那个同学是 vv 二, vv 二你可以参考这个,如果 vv 三的话,你用它啊,这是 饿了么 ui 的,饿了么 ui 提供了一个呃,虚拟滚动,但是它的虚拟滚动的话,嗯, 不好的,它好的点就是它解决了 v s e table 在频繁的更新某个字段的时候它会卡住的问题啊,这个它就没有,但是它就是用户体验没那么好 啊,你看这个滚动条永远怎么大啊?在数据量比较多的时候,他的用户里面没有在某一某一某一情况下啊,就是他没有那个 vs 他也不好用啊,大概是这个意思。 好吧,这个就就是这两个的一个区别。之前我也分享过啊,在这十万条数据,是吧?你们这一万条,这用这个户绝对没有问题啊,我用了大概十几万条,二十万条啊,去展示都没有问题。
粉丝8538获赞9.4万

内存溢出的定义,简称录内存溢出 out of memory, 是指应用系统中存在无法回收的内存或使用的内存过多,最终使得程序运行要用到的内存大于能提供的最大内存,此时程序就运行不了,系统会提示内存溢出, 有时候会自动关闭软件,重启电脑或者软件后,释放掉一部分内存,又可以正常运行该软件。而由系统配置数据流、用户代码等原因而导致的内存溢出错误, 即使用户重新执行任务依然无法避免。接下来我们要解决如何定位内存溢出问题。定位内存溢出的步骤第一步,定位 cpu 最高的服务进程先找到 cpu 占用比较高的进程 top c, 进去后按 shift 加 p 键, 一般异常的进程 cpu 的占用会很高,记录下这进程的可以查看指定进程 cpu 情况。第二步,查看指定进程 cpu 情况 top cpp 命令查看此进程占用 cpu 最高的县城,记录下县城的 ped, 也可以将相关信息保存下来。 top hpp 楼 cpu 原因 cpu text t 到此我们就找到的最占用 cpu 的进程以及相关线程。第三步,分析日志和代码 如果已经知道是哪个程序导致了内存溢出,那么我们就得学会分析日志,一般在 lt memory 的上方我们都会有各种日志的输出来标志,现在这个时间点,我们的程序执行了什么操作,导致了我们的这个内存溢出? 分析到这里就轮到看代码了。第四步,检查的内容方向第一步,查看数据库相关内容,例如查询的数据量是不是超过程序之前的设定,例如数据库连接有没有正常释放?第二步, 集合对象使用后有没有正常释放?第三步,代码中有没有死循环或者地规函数?内存溢出的解决方案, 第一,可以直接加内存。第二,检查错误日志。第三,查看 out of memory 错误前是否有其他异常或错误。第四,对代码进行走查和分析,找出可能发生内存溢出的位置。 第五,使用内存查看工具动态查看内存使用情况。关于内存溢出,你有什么好的解决方案吗?欢迎大家评论区留言。

hello, 今天来给大家分享一下我们内存溢出该怎么去排查,我这边用的一个分析工具呢是 eclipse memory analyzer, 那这样的一个分析工具呢,是我觉得到目前为止我用的是比较好的一个。呃,工具。那我这边呢有一个 demo 啊,就是很简单,就是往这样的一个数组里面呢,不断的添加我们的拜的数组,大概是一兆, 然后我这边呢先要添加上这样的一段参数啊,这个意思呢是说我们初始化和最大的堆内存呢是二十兆, 然后这边有一个 help dump on out of memory error, 意思就是说我会在我内存一出的时候呢,会生成一个 dump 文件,然后存储在我们这个目录下, 然后呢我就把它添加到这边,然后应用一下。好,然后我们去运行一下,好运行之后呢,他就会在这样的一个目录下面啊生成了这样的一个 当铺文件。我们现在用这个工具呢去给他打开。 好,打开之后呢,我们点完成,这边有个 overview。 那分析内存溢出的一个步骤呢,大概有三步,我总结了一下。首先第一个呢,我们去看占用内存过大的一个对象有哪些, 然后呢第二步我们就看这个对象是被谁引用的。第三步我们可以再定位到具体的一个代码。首先呢我们去看一下占用内存过大的一个对象有哪些,我们可以去看 histogram 这样的直方图, 比如我们点击这个去点击这个,这个标志呢,就看他的一个直方图,这边显示的呢是我们内存占用的一个大小,可以看到拜的数组他占用的是比较大的,然后这边有一个浅堆和一个深堆,那浅堆跟深 堆呢,类似于浅拷贝和深拷贝的一个关系,浅堆的意思呢,只限于他这个对上占有内存的一个大小。然后第二步呢,我们看一下,他是背身引用的,我们可以去看 dominate tree, 就是支配数,然后我们可以点这样的一个 符号,那这边呢可以看到支配数的一些信息啊,其实呢就是我们的一个引用关系图,比如说我们啊魅县城这一个,他占用的一个深堆是比较大的,我们可以点进去看一下, 然后我们可以看到啊,这个里面呢有个 released, 他占用的一个啊内存是最大的,然后我们点进去看一下,这里面呢就有一个数组,然后呢占用了很多的一个败的数组,对吧? 那其实我们就找到了他是被谁引用的了,是被我们孟县城里的一个 released 给引用的。那第三步呢,我们可以定位到具体的代码,那定位到具体代码呢?我们可以点击 thread overview, 比如 是我们点击这个齿轮的这种形式,我们点进去,然后这边呢我们就可以看到县城的一个概览信息。那同理啊,我们魅县城他占有的一个深堆是比较大的,我们就可以点进去看一下, 然后它这个里面呢,其实就已经有一个 out of memory ever 异常了,对吧?这个里面呢就有一个 release 的一个集合,然后里面有一个 element data 的数组,引用了我们很多的一个对象,对吧? 那我们可以看这样的一个代码,就是 om test java 的一个二十三行,其实就已经定位到了我们 om 呃内存一出的一个行数了,二十三行呢,其实就是这一行我们不断的去添加一兆的一个数组 往我们这个集合里面。其实 demo 呢是比较简单的,但是不管是呃多复杂的 demo, 我觉得排查他内存溢出呢是比较简单的,就是这三个步骤, 反正我觉得是如果代码是你自己写的,那你可能很快就改完了。但是如果是一些中间键的代码而造成的内存溢出呢啊,就要求你对中间键的一个实现有个基本的了解才能解决。那我们之前生产上遇到的一个问题呢,就是我们县城池里面的一个有接对列啊,他设置的参数呢过长, 他设置了五千个,但其实我们的任务放到一千多个的时候呢,他就有一个内存溢出的问题了,但是他内存溢出排查的步骤啊还是这几步。那如果大家想要这样的一个 demo 以及之前写的一些 demo 的话呢,大家可以到这来 这个,然后去给他发一个消息,像这样就可以拿到我们的 demo。 好,今天的一个分享呢就到这。

b 包一定会导致内存泄露吗?很多人都会这样说, b 包一定会导致内存泄露。昨天在我们的魔鬼训练营的群里面也在讨论了这个问题,有没有可能我们再去深入思考一下 b 包,它是我们用户可预期的情况,对不对?就比方说我们随便定一个方式,弹入一个, let a 等于一, let b 等于二, controllog a b, 然后我们执行一下这个方格,信这里面的垃圾回收机制,新版浏览器标记清除机制会把所有的内部函数执行完,里面的变量,所有变量都会回收掉,但是我们要在内部再来一个,呃, window 点 a 等于一对吧?你函数执行完,它里面内部 a 会被回收掉吗? window 点 a 会被回收掉吗?他不会,他系统会认为你是在被引用,所以你不会被消失,这就是 b 包了,内部函数使用外部函数的变量,保持引用内部访问外部的作用欲,这是内存泄露吗?这不是内存泄露,这是我们用户可预期的一个情况,这就我们为了要用这 这个特性,对吧?就为了要用他,他怎么会是那种泄露?道理上说不通呀,对不对?然后我们再去看,对吧?这个论点就能推掉来,他一定会被垃圾回收机,他可能这和垃圾回收机是没有太大关系了,所以这时候我们要去深入去思考一下,就包括我们刚刚说到的迪棒斯,我们 like 他们为那,然后瑞特瑞特出来一个函数,然后内部函数 用外部函数的变量形成了引用,引用他不会随着函数执行完毕而而去消失。然后呢?如果我们用普通函数去执行的话,他不会的, 还有普通函数执行,他达不到我们的效果,因为拿不到上一次定时。就比方说我们在 input 框这个业务场景下,我们点击一次,对吧?搜索一次,点击 n 次,对吧?搜索 n 次,这时候就要去优化节省带框,所以我们在点击结束之后多少秒才开始去做请求,迪邦斯的一个应用场景, 防抖的一个应用场景,然后这时候我们在第一次点击就把直行代码走到了 set 他妈,然后第二次点击,其实我们要去拿到 上一次定时,如果你不不拿到上一次定时,你两个定时同时执行啊,你会有多次请求的。包括 b 包还能选的垃圾回收机子,就包括以前的标记清楚和引用技术,又扯到了循环引用等等一系列问题,包括哪个版本的浏览器解决了新就是循环引用,老版本的 r 一六七 对循环饮用是怎么处理的等等一系列东西用不到,但是别人如果问到你,你知识的广度就没有了,可能就把你直接挂掉了。你不要看这个小问题啊, 很多东西你会发现你越去往后生你圈越有意思。那标记清除算法,用技术算法,他怎么样去做引用呢?怎么样去做循环引用呢?等等,这些东西有去研究过吗?包括新生代、老生代那些算法怎么样的?去研究过吗?没有,你见过更多的是没有去做过的。

前端导出百万条也可想要数据,那么最佳的方案,咱们今天就聊聊怎么样去实现。你不要说这种需求不合理啊,我给大家解释一下,如果放到后段去做后段服务器对吧?不管他是扎瓦写的也好,还是构写的也好,那么如果有多个请求吗?如果夫妻的内存不够,很容易瞬间被占满, 有可能会导致内存泄露在一个你夫妻的 cpu 使用率也会持续的上升。登成 excel, 登成这种奥地日文件,其实非常持 cpu 性能的, 生成了一个赛哦的这个操作,让每个客户端去做,这样的话你就算占用 cpu, 他也是每个客户端占用的,所以说对这个服务器 影响其实不大的。展现看需要用到的库,生成 axl 的这个库在该号码上其实就是 c 的 gs 啊,这个用的还是比较多的,成为我的这个 axf 文件, 我是用的这个第三方的库,在疙瘩哈巴上也是比较多的。这个是我实现了一个 demo, 我导出了一百万条的数据,我咨询一下大家,可以看一下, 大概执行了四秒左右,可以看一下这个一个赛文文件有一百万条数据,接下来带着大家去看代码,我在这点击这个按钮的时候,他会执行这个方法,主要逻辑是在这个里面封装的,那么这个方法我首先是我要传过来我要导出的数据,然后我要分片, 默认是按照一千进行分片的,这个是他导出来一个进度。第一步呢,按照数据把一定数量拆分成若干个数据片段, 比如说一百万条数据,我单次处理一万条,那么我可以拆成一百个分片,拆分的意义在于我们可以控制单次处理和数据量,确保浏览器不会因为过多的执行数据而卡死。 第二步呢,我要创建这个数轴啊,用来存放你要导出的这个片段啊。第三步呢,我要创建表头吗?我开始进行便利分片。第四步呢,这个地方我要获取数据一万条数据,每一次的一万条数据,正常的话就是这个数据啊,应该是后端一次性返回的一百万条, 这样的话我就拿到我的数据一百万条,我按照就是说一万条一个分片,相当于我每次从里面取一万条就可以了,然后我获取完了之后我要便利分片,便利时我要格式化这个数据,每个分片要转换成这个一个小小片段。 然后呢我还要计算他导出了一个进度,最后呢,我执行完之后,对吧?我要把进度设成百分之百。第五步呢,我要创建这个帮对象,第一个是传一个输入啊,第二个是设置他的这个导出的格式啊,十六进制需要设置一下,不然的话 出现乱码的。然后最后呢,我用这个库转成这个赛文件,咱们再执行一下看看,刷新一下这个库存台的打印,这个整个一百万条的执行,他用了四点六秒的时间啊,咱们也可以就是说如果防止这种页面卡顿的话,咱们可以在这适当的暂停 啊,暂停相当于咱们能看到这个进度条的变化,但再执行一下,我点击的时候这个进度条正在走,对吧?和你后面打印的进度它其实是一样的, 同时完成了这个如果加上这个适当的暂停的话,他时间就比较久,大概得用九秒左右。这种方式啊,其实还不是最优的方案,大家有没有思路可以优化优化这个思路我放到下期进行讲。

在 crom 的开发者工具中,我们可以使用性能监视器,再使用内存面板,按时间线记录内存分配的情况,定位并解决内存泄漏问题。 如果你还不知道怎么操作,接下来我带着实力给大家讲解一下啊。大家来看这样一个例子,那么既然有内存泄露的话,那么肯定我们在使用我们的程序的过程中,它的占用的内存会不断的增长,并且 不会有这个下降的趋势,那么我们可以来到这个,来到这个 chrome 的这个性能监视器面吧,然后我们可以通过观察这个 gship size 来观测我们内存的变化情况,如果他一直在上升的话,那么他可能就有内存泄露的一个风险,比如说我现在,我现在就使用我的这个应用,是吧?我在这个电影院啊,电影和影院这两个态度之间来回的切换,切换的时候大家注意看那个 gs 黑 size, 它其实 在不断的增长,刚才只有几十兆,现在到了一百多兆了,是吧?好,我继续,我继续点的话,那么可以看到他的 aps 已经来到了两百,这个时候我们使用这个强制的一个内存回收,可以看到也可以看到,最多他也只能回收到一百兆左右, 所以我有有理由怀疑这里是有内存泄漏的,接下来我怀疑他有内存泄漏,如何给他找出来呢?我们就得用到 crom 开发者工具的另一个另一个功能呢, 我们来到科尔姆开发者工具的这个内存面板,然后在这我们可以选择按时间线来记录内存分配的情况,点击开始, 接下来的话,我就可以重复我之前的这个操作,在电影和影院之间来回的切换,嗯,在我切换的过程当中,大家就可以看到,那么右侧就会不断有这个,不断有这个蓝色的条,然后它代表的就是我们现在在内存中当中已经 分配的内容,而且他并没有得到释放。然后接下来我们停止记录,好停止记录之后呢,我们可以选中,我们可以聚焦到某一个这个条上面,然后在这个下面的一个列表当中就给我们列出来了那么这一块内存中当中所包含的所有电量, 然后这些变量的这个构造函数,我们可以看到啊,有这个,有斯俊,然后还有 vivo 的 component, 我们可以注意观察一下,这个有某一些可能,就是某一些实力特别大的特别多的一些变量,比如说这个 是正式吧,这得有多少个了?个十百千万,十万、二十八万,那好像是有些离谱了,然后我们可以点开把它看一看,他可以看到那么他确实是有很多支付串,然后这个支付串呢,我们可以选择其中的某一个,然后可以看到这个支付串的引用,他是在 window 的一个叫做历史的 变量中。啊,那确实,那这呢可能就是我们的一个怀疑对象了,那么我们可以来搜索我们的原代码,然后 就可以看到,那么元旦码当中确实有个地方往这个 window 的历史当中不断的这个存储一些内容,是吧?那么这个内存泄露的原因就被我们找到了,那这就是我今天要给大家分享的所有内容,如果大家觉得我的视频对你有所帮助的话,千万不要忘了点个赞哦!


如何检测网站内有无内存泄露?你是前端开发或网站管理员吗?你有没有检测过你的网站有可能有内存泄露?通常情况下, gs 应用程序会将内存分配给堆取,然后使用垃圾收集器自动处理内存。 如果代码中引用了不再需要的对象,垃圾收集器将无法完成其工作。那么我们需要进入谷歌浏览器工具中的性能面板。在使用网站时,点击蕊 core, 他会记录每秒的 cpu 使用情况,并在使用过程中拍摄一系列的屏幕截图。 我们着重关注的是这条蓝线,他显示了堆中的内存量,如果他不断增加的话,你就需要转到谷歌中的内存选项卡,记录堆虚快照,并检查其中的实际值。这就是你如何发现内存是否泄露的方式。

大白话聊战一出,也就是 steak overflow, 咱们大家肯定都知道 steak overflow 这个网站对吧?他是全球最大的一个技术问答网站,咱们国内也有很多程序员在使用,他的官方网址呢,就是 stack overflow 点 com style of flow 这个名字,它其实是一种程序的运行时错误,咱们中文翻译过来呢,就叫做战役初。 这里的站也就是 stack, 它并不是数据结构中的站,而是程序内存中的一个分段,或者说是一个分区吧。 呃,咱们的程序呢,可以使用的内存有很多。呃,不同的内存呢,它有不同的作用,为了方便管理呢,操作系统会对这些程序的内存空间啊进行一个分区,把具有相同作用的内存呢,它都划分到一个区域之中。严格来说的话,这里的内存空间 间呢,应该叫做虚拟地址空间,或者叫做虚拟内存空间。不过为了照顾大部分初学者,这里我就不照本宣科了,我就把它叫做内存空间。哎,你比如在经典的三十二位环境下,程序可以使用的内存的是四个金币。 雷尼克的操作系统呢,会按照咱们这张图片来进行分区,大家可以先把视频暂停一下,仔细看一下这张图片,对各个分区呢有一个大概的印象, 图片里的内核空间是被操作系统所占用的,我们没法直接干预。图片里的保留区域呢,也不是用来存储数据的,他只用作一些特殊的目的。 呃,你比如可以让你的空指针指向这里,除了这两个区域,剩下的那些内存呢,才是被咱们自己所 编写的程序所占用的也就是图中的圈一和圈二两个部分,这其中呢,圈二在程序运行期间会一直存在,直到程序销毁才能被释放。圈一在程序运行期间会不断变化,也就是被不断的分配和释放。 在缺一这一部分中呢,咱们注意他有一个分段,就是叫做战,这一部分内存呢,他只有在一种情况情况下会被用到,就是吊用函数的时候。 函数被吊用的时候呢,有很多数据需要暂时压入占中,也就是存储的占中,包括 我们在代码中定义的数据,比如食餐局部变量,局部数组,局部对象,返回值等等,我们可以把他们称为局部数据。还有就是我们在代码中看不到的数据,比如函数的 啊,返回地址,一系列计算器的值等等,这些都是函数调用所需要的一些隐藏的数据。 局部数据呢,是我们在函数内部定义的,他们的作用欲呢,也仅仅限于函数内部,只有等到函数被真正定义的时候,他们才会被实际创建出来,也就是分配好内存。 至于隐藏数据呢,他是为了实现函数的调用过程,并保证在函数退出的时候能够恢复到他调用之前的场景,而不得不额外增加的一些溶于数据。这些隐藏数据都是由编译器分配的,咱们程序员自己是没法来干预的。 以上咱们提到的这些所有被压入战争的数据,通常都被叫做战争,或者叫做函数记录。函数每调用一次都会生成一个战 针,这个过程被称为函数入战,当函数调用结束的时候呢,战争就会被销毁,腾出自己的内存来给其他的函数使用,这个过程称作函数出战。函数调用开始的时候,先调用的函数先入战,后调用的函数呢,他后入战, 等到函数调用结束的时候,这个顺序他又是反过来的,也就是也就是后调用的函数先出站,而先调用的函数呢,他又后出站。你看看这个过程,他和函数,他和数据结构中站的进出方式是不是一样的呢?所以咱们这一段内存啊,就被叫做站。 在继续讲解占一书之前呢,咱们先来科普一个常识,就是一个县城他拥有一个站,站中的数据呢,是被当前县城所独占的,其他的县城啊不能访问。为了保证在一个建成里边可以 同时运行多个现场,比如几十个或者成百上千个编译器呢,他不会给单一的现场分配太多的占空。占内存一般也就是一照到八照, 而且站内存大,站内存的大小呢,他在程序编译的时候已经确定好了,等到咱们的程序在运行的时候呢,就不能改变了。所以如果你的程序使用的站内存超出了最大的值,那么运行的时候呢,就会发生一个占一处的错误。 一般情况下,站内存都是够用的,但是如果遇到以下两种情况,那么站内存呢,就会捉襟见肘 啊。第一,咱们在函数内部定义了一个大规模的数据,比如你定义了一个很大的数组。第二呢,函数调用的层次太深,导致咱们的战争呢,持续性的一个 积累,比如发生了,比如函数的嵌套吊用这两个就是发生战役出错误的典型场景。当然了,战内存的大小呢,可以通过编译参数来自己设定,人为的把战内存调大或者调小,只是一般不会有人这么干。 好,接下来呢,咱们再看一段简单的战役初的代码,在这个代码当中呢,咱们定义了一个很大的数组,他需要占用两兆的内存,而我们常用的 vs 编译器,他的战内存啊,默认只有一兆,所以这个代码在默认情况下就是会发生战役初的, 咱们可以使用 vs 二零一零的第八个模式来进行编辑,然后再运行他就会出现这个图片里的这样一个错误, 你看 steak overflow, 这就是战役初错误,战役初呀,他是一种治病的错误,发生战役出错误以后,咱们的程序就没有办法再继续运行了,你只能关闭他,没有其他的挽救措施了。 好,那么到这里呢,咱们的战一出就算讲完了,如果大家喜欢这种干货视频,可以多多的点赞和转发。 如果数据好的话,后边我会再继续讲解一系列的那个内存话题,比如内存泄露程序的内存布局,虚拟内存地址,空虚拟地址空间等等。好吧,呃,大家就一,大家就一就一箭三联吧,拜拜。

每天三分钟讲明白一个 c 加加知识点,内存泄露魂内存一出。我在面试时经常会问到这个基础的问题, 虽然概念很简单,但有时往往不在意,在面试时就会出现答不上来的尴尬情况。还是讲一个故事来说明这两个的特点。我们在家里肯定都会遇见过忘关水龙头导致家里遭水灾的情况,这种现象就包含了 内存泄露和内存溢出的核心概念。但我们打开水龙头,其实就是在向系统请求内存来处理我们自己的程序,但是我们处理完之后没有及时将用过的水排掉, 这就会造成内存泄露。更糟的是水龙头还忘了关,一直在不停的出水,系统不停的分配新的内存出来,水池的空间毕竟有限, 水最后都会溢出来,这就是内存溢出。当然 c 佳佳的智能指针时,可以避免忘记释放内存的情况,所以 c 佳佳为什么比较难,其实最核心的是他实在很灵活,能够操作内存,最大化的 去优化系统的性能,所以很多潜入式系统涉及硬科技领域都会用到的。当然性能优化是一个很大的话题,这个涉及到业务逻辑、底层机制算法等内容,后面我会专门讲一讲 c 加加上性能优化的常见方法和思路。

咱们去面试的时候,面试官有可能问浏览器怎么样做缓存?我相信好多同学都知道这两个 api 它其实容量是有限制的,前端我们要处理几个 g 的这种文件怎么办?所以说咱们今天就讲一讲前端大容量这种缓存方案。如果做过外部结构的同学可能知道,咱们如果加点这种文件的时候, 那么这种文件体积就比较大,如果从服务端加载的话,那么网络耗时也会比较长,整个特别影响咱们用户的体验,对吧?所以说咱们就介绍一种方案叫影影单地币,那么他其实可以让数据在浏览器自律缓存,允许这种存储大的数据量,还提供这种接盘, 那么影带 db 他不是这种观影睡裤,他更接近这种浓缩口的睡裤,他的存储其实就是 ky 用的这种形式,那么影带 db 他其实比较底层嘛,所以说我们一般都用这种第三方的裤对影带 db 做了封装,这个 官方文档他也提到了,就说他的 aps 是非常强大的,但是使用起来就是太复杂,所以说我们一般都会用于这种第三方的这种酷,这样的话对我们开发者来说更加的友好。那么这个影带 db 它不仅可以存储支付串,也可以存储这种二进一字文件, 报个对象对吧?也可以存储这种图片,或者说是视频都可以,那么咱们今天就以存储一个视频的方式来给大家做一个演示。这里是带网部分啊,首先我外练了两个文件,一个是阿卡克斯请求的文件,还有一个专门封装影带 db 的一个库, 那么这个库其实就在官方文档里面,他也提到了,就是这个。那么首先我们在这地方定了一个这个视频的标签,我用阿贾克斯去加载这个文件,这个文件就在我本地,那么这个文件其实比较小,才实照的一个大小,这个地方我去打印他的开始时间, 对吧?开始存的时候,对吧?然后呢这个地方我做了一个循环,我做了循环,我循环了一百次,一百次的话因为我这个文件是实照,对吧?一百乘以实照,也就是说大概能存一个 g, 也就是说我这地方设置他的存储设置了存一个 g 的这个文件, 那么这个地方就是他那个这个库提供的一篇,我去晒他,晒着他的这个 k, 对吧?他的歪扭其实就是每一个文件吗?对吧?然后我循环了一百次,对吧?我存完一百次之后,算一下他存储用了多长时间?存储完成的时间 减去纯属开始的时间,我存完之后我要读取出来,对吧?我要还要计算一下他读取出来用的时间,我要对比一下他存的时间和读的时间。存完之后呢,我要把我存的这个文件读取到,读取到之后怎么办呢?我要给这个 read 标签设置这个我的 这个视频让他播放在页面上,整个的这个是一个代码的落地,那么咱们看一下时间的效果,我刷一下,看一下这个加载的时长,因为这个加载时间是比较长的,那也就是它存的时间比较长,我这地方就快进了整个这一个 g 的文件的存储,我大概用了 一万四千毫秒,那么我读的时间其实用了还不到一秒钟,特别快,那么咱们看一下他存储的位置,存储位置他就在这个点击这个标签,然后到这个银贷地币,然后这地方有一个这个存储,对吧?本地的 ui 二,看到 我每个文件的存储,它是以 k y 扭的形式存储,实现起来非常简单,大家有没有更好的方案来存储这种大容量的数据?如果有的话,欢迎评论区留言讨论。

好了,同学们,那咱们这一小任务呢,解决一下我们的路由缓存问题,哎,我们先过来认识一下什么叫做路由缓存问题,我们怎么就遇到他了呢?好,我们过来看哈, 大家看,其实所谓的路由缓存问题在官方文档里边呢,有这样一个说明,他说呢,使用带有参数的路由时需要注意哎,当你从这个路由一切换到我们的路由二的时候,相同的组建实力会被复用,为啥呢?你看哈, 前面这个 us, 后面呢是不是也是 us 呀,他们只有这个参数不一样,当只有参数不一样的时候呢,就会走这个,哎,组建实力的一个复用了, 副用呢,本身是为了哎,减少我们销毁重建时的一个性能损耗,但是呢,他也会带来问题,他带来问题是这样的,你看这,你看这句话,他说呢,意味着组建的生命周期钩子呢不会被调用, 这个事呢,哎,就比较大了哈,你想市面周期钩子呢都不会被调用了,你的新数据还能返回吗?哎,是不是不可以返回了?所以说呢,他给我们当前这个分类业务带来问题也是一样的, 由于咱这个分类呢恰好满足他这个条件,所以呢他走了一个组建实力的复用,导致咱们的分类数据呢无法更新了,我们过来呢给大家演示一下哈,好,过来大家看哈,我们现在是一个居家,当我点美食的时候,大家注意观察下面内容的一个变化点美食 有变化吗?哎,是没有啊,这个地方是不是变了呀?我们再试一下哈,我们再点一下服饰点,哎,已经切过来了,这也变了,但是呢,下面一动不动,这就是我们现在遇到的缓存问题,由于呢咱们只是一个参数方式变化,所以说呢,他这 这个默认直接走缓存服用,我们的实力导致呢,我们的新数据压根呢回不来理解哈。好了,那面对这样一个问题的话,如何进行解决呢?咱们过来一起思考一下啊,你想 他既然是由于组建实力复用导致的,那解决方向呢,无非是两个,第一个,我们可以让这个组建实力呢不复用,哎,我不让你复用了,我强制呢,你销毁重建, 那这样的话,我的生命周期是不是又可以发送了呀?哎,对不对?好,第二个,那监听路由变化,如果我们能知道路由呢,什么时候变化了,变化之后呢?执行我们的数据更新操作是不是也能走的通呀?哎,所以说呢,两条路,两个思路, 那接下来呢,我们就分别按照这两个思路呢,给到大家一些解决办法,我们先过来看一下我们的第一种解决办法哈,他呢是让这个组建实力呢不再复用, 看看怎么玩好,我们过来实现起来呢,其实挺容易,我们只需要呢给这个 rooter view 添加一个 k 就可以了,具体怎么做呢?大家看我们以这个当前路由的完整路径为 k 的值,给我们 rooter view 呢组建绑定过去就行了。看这里, 我们找到我们的这块 view, 给它加上一个 k 属性,用 dollar root 下面的一个 full pass 就是完整路径呢,作为一个独一无二的 key 给它绑过来就行了,这样的话呢,它就没有缓存了,哎,就是不用, 就是不会去复用了,为啥呢?那其实这里也有我们的理论依据啊,在微友官方呢,提到这样一句话,他说呢, 我们这个加 k 啊,虽然最常见的用力呢是和这个 vivo 配合,但是呢,它也可以用于强制替换一个元素或者组建,而不是附用它,那你看正好满足我们当前这个要 要求对不对?那真的可以做到吗?那咱们接下来呢,打开我们的代码区,咱们给他验证一下哈。好,回到我们的代码区, 那咱们找到我们的 rooter view, 它呢应该是我们的二级路由里边。点过来找到我们的 industrial, 这个地方是不是一个二级路由的出口呀?好,我们过来给它呢添加一个独一无二的 key, 添加 key 破坏他的复用机制,哎,让他强制销毁重建。 来,我们过来看,给它加上一个 key, 后面呢加上一个 dollar root 下面的 footpass, 保存 好。回到我们的项目里边,我们看一下这次他有没有发生变化哈,我们点击一下母婴走,看到没有? a 数据是不是变了呀?点一下购户走 a 是不是又变了呀?那其实呢,我们也可以在我们的 浏览器 network 呢,你会发现他的请求呢,就会发送起来了。看哈我们点居家走,看到没有,两个接口是不是都在呀?一个是分类接口,一个是 bander 接口。点美食走,看,是不是又发起了呀? 哎,这是我们所谓的第一种解决办法,他利用的是我们强制破坏,他不走缓存,不附用我们的实力, 哎,那我们的生命周期呢,是不是又可以重新的跑起来,我们的请求也会发送起来,那我们的数据当然可以更新了,对不对?但是这种办法呢,有一个问题,大家说是什么问题啊? 你看哈,这几个分类里边,我这个 banner 图是不是一样的呀?我这个接口还需要你重新发送吗? a 是不需要呀,所以说呢,我们这个加 k 的方案呢,有一个问题,就是他太过的粗暴,哎,他把整个实力呢都学会重建了,所以说呢,组建里边的所有的请求都会重新发送,存在一定的浪费。 那么如何只把这个分类的数据给他请求回来,我这个 banner 不动呢?什么意思?也就是说哈,我想让他点击的时候呢?大家看这里现在是不是有两个请求呀? 我想做到呢,他只发送一个请求,哎,就是我们这个 category 这个请求发送起来就可以了,因为 banner 都是一样的吗?你还重复发送我干嘛呢?是不是存在浪费啊?哎,那咱们接下来再看一下 的第二种方案,它是一个精细化的配置方案。我们过来看第二种方案呢,它采取的是监听路由的一个变化,这个勾字函数叫做 before root update, 这勾子函数呢,可以在每次路由更新的时候呢,他会每次都执行。那你看,我们既然知道了路由什么时候变化,在他变化的时候,咱把这个更新数据的逻辑放进去是不就可以了,对不对?那接下来呢,咱们再用一下这种方案呢,去做一下这个事,看怎么来玩哈。好,回到我们的代码区, 咱们呢先把这个地方呢给他注掉啊。好,咱们复制一份给他呢注掉,为了避免影响,我们先把这种方案呢给他干掉,把 k 呢去掉。大家知道呢,这种方案是可行的啊,接着呢,咱们开始去给他做一个精细化的配置,来到我们的 category 里边。好,来到目标组件点过来,大家看哈,我们的目标是什么?是不是想让我们的点击分类切换时,我们的请求 get category 可以重新发送起来呀,这是不是我们的目标呀?让我们写一下哈,我们期望, 哎,这是我们的目标,我们期望呢,在路由参数变化的时候, 可以把分类数据接口呢重新发送,这是我们最终目标。而这个 banner 咱是不是不用动它呀?好了,那接下来呢,用一下我们刚才这个钩子函数。好,我们先把它导入进来, 需要从我们的 viewuter 里边导入,它叫啥呀?哎,叫做 on before route the update。 好,下面这个导入导入以后呢,咱们可以直接过来执行一下他。好,在这个地方呢,执行,他接收一个参数,是一个回调函数。 好,里边呢,我们给它,可以给它先打一个简单 log 哈,我们叫它路由变化了。 好了,不着急,咱们过来看一下当我们切换路由的时候,他能不能打印出来这个结果,如果能,是不是证明呢?我们的监听是生效的呀。好,那过来呢,我们看一下他能不能生效。 来到我们的 ctrl 区域,好,清空一下,点一下美食,看到没有?路由变化了,点一下我们的居家走,你看又一次对不对?那证明我们的监听是不就已经 生效了呀?哎,我们知道呢,他什么时候进行了一个,哎,更新操作好了,回来接着呢,我们回到目标,我们呢,想在路由变化的时候呢,把这个分类数据是不是接口呢,重新发送一下呀? 那这个重新发送是谁呀?哎,对了,是不就是我们的 get category 啊?好,所以说在里边呢,我们需要呢,重新把这个函数给他发送起来, 对不对?哎, ok, 但这里呢,有个小问题啊,我可以告诉大家,什么问题呢?就是说呢,我们调这个函数的时候,我们需要用到的路由参数是不是变化之后的参数呀? 哎,我们写过来哈,现在它存在一个问题,因为呢,我们需要使用最新的路由参数请求, 哎,最新的分类数据,而我们这个地方呢, root parents 点 id 呢,它是一个滞后的,哎,它存在一个滞后性,它拿不到最新的,那怎么办呢? 哎,别着急哈,这个地方呢,他还非常贴心的给到咱们一个,哎,参数对象叫做 to to, 代表什么意思呢?回想一下,我们之前见过那个 to, 他代表的是目标路由对象,哎,目标路由对象,咱们可以尝试过来呢,给他打印一下,看哈, log 一下我们的 two, 看看他是谁,好,过来,好伤心一下, 好,我们点击切换哈,走你路有变化了,你看,答应出来了,过来以后呢,看里边,它是一个完整的对象,其中呢,有一个 parents, 看到没有,里边有个 id 五零零二,你看正好是切换之后的五零零二,没有问题吧,那咱们是不是就拿到他最新的参数呀?那回来呢,我们给他继续写回来,在这个地方,咱们呢只需要用一下我们最新的参数就可以了。那怎么办呢?你看 用参数的位置呢?是在这儿诶,我得到参数呢,是在这儿,我怎么样把这个 to 给它放到这个地方使用呢? 哎,聪明,我是不是可以在掉函数的时候给他传下去呀?哎,我把这个 two 点儿我的 parents their id 是不是可以传下去呀? 我既然给你传了,你是不是就得接呀?哎,在这个地方我得接收一下你传过来的 id, 对不对?那我这个地方就得变成一个 id 了呀。那我原本一上来,那 那个参数是不是丢了怎么办呢?是不是可以给他来一个默认参数呀?这个地方呢,我们可以用一个 root 点 parents 点 id。 那你看这样写完呢意思呢?变成了,如果你给我传了参数,哎,这个地方是不是传了,我就以你传的为主,是最新的,如果你不传的话,我就是一个默认参数,这样的话,两种模式是不都适配了呀? 哎,我再强调一下哈,这样写法的意思是说,在一开始上来时候,这个地方是不是没有传,没传的时候呢?我用是后面这个参数, 如果你在下面传了以后,用的是最新的参数,这样的话呢,初始化的时候和路由更新的时候我都是可以适配到的。 ok, 好了,到此呢,咱们就写完这个地方的逻辑,我们过来看看他对不对哈。好, 回来呢,我们给他测试一下。来到我们 network, 我们先刷新一下,保证呢,他的第一次请求是没有问题的,看 cantagree banana 什么都可以呀。好,我们清空一下,这一次大家注意观察哈。我在切换的时候注意观察他到底是有两次请求还是只有一个 cantagree 了,我们点击就加, 看到没有,就剩下一个了,那个 banner 是不是就不请求了呀?哎,是不是这样看起来他的性能呢应该会更好,因为呢,我们的请求就剩下一个,哎,就剩下一次了,那一次呢,不效的就没有了。 好了,那到此呢,咱们两套方案呢就都做完了,那过来呢,咱们稍微做一个小的总结。好,我们过来,那我这里呢准备了两个问题,看第一个,如果缓存问题产生 的原因是啥呀?哎,对了,是不是当我们只有路由参数发生变化的时候,他会直接服用组建实力啊?哎,这本身呢是一个设计上的问题啊,为了一个性能考虑他会服用, 那复用不要紧,它会导致我们的生命周期不发送了,那我们的 on monty 是不执行呀,那我们的新的请求是无法发送,那当然新数据呢?回不来,无法更新 对不对?哎,这是我们路由缓存问题产生的原因哈,那第二个两种方案呢,都可以解决我们的问题,一个是加 k, 一个呢是用一个勾子函数,那这两个如何来选择呢?在实际开发时候如何选择呢?大家想怎么做呀? 哎,看场景呗。那如果呢,我们在当前开发时候呢,他非常在意这个性能问题,哎,比方说呢,产品要求 我们必须呢不能有重复的网络请求,那这个时候呢,我们就选择我们的勾字函数就可以了,他可以做到一个精细化的控制,因为呢,我把这个 钩子呢给到你,你愿意去更新哪块数据你就更新哪块数据,对不对?哎,我们把它叫做精细化的控制。那如果呢?我们压根不在意性能问题,那我们就选择 k 呗。 k 我们只需要给到他一个独一无二的值,那这个时候呢,他就会破坏掉我们的组件缓存, 那简单粗暴,但是呢会存在一定的浪费,哎。 ok, 好了,这是我们最小节的所有内容哈,那回到我们代码区,咱们给他做一个提交。好,这一小节我们解决的是一个路由的缓存问题。好走, 漏油缓存问题解决。走好了,我们先停一下。

哈喽,大家好,我是有十四年家网架构经验的麦克老师。今天呢,我们将探讨一个与家网应用性能和稳定性密切相关的话题,那就是内存线路问题,以及如何去诊断和解决它。另外,我把往期的视频内容整理成了一本面试突击手册, 有没有非常详细的文字版本的答案,包含各个一线大成的高频面试真题,有需要的小伙伴呢,可以在我的评论区的置顶中去免费领取。 内存泄露呢,是指在程序中分配的内存空间无法被正常释放或者回收导致呢?应用程序的内存消耗不断增加,最终可能导致应用程序内存泄露或者程序崩溃的问题。 内存泄露通常发生在两种情况下,第一对象引用未被释放,某个对象呢,只有对其他对象的引用,但这些引用不再被使用,说阻止了垃圾回收器把这些对象释放掉。第二个是数 结构的不合理使用,比如说使用缓存或者集合的时候,如果不小心保留了不再需要的对象引用,可能会导致内存泄露。下面我们来看一下这个问题的完整回答。 对这个问题呢,我会从几个方面去进行一个排查和解决。第一步是观察应用的内存使用情况,来确定是否存在内存的泄露问题。 通常呢,我们可以通过各种监控工具或者 gms 来去完成这样一个定位,如果观察到应用程序的内存使用量在长时间运行之后持续上升而不下降,或者随着时间的推移,应用程序的响应时间逐渐增加,或者出现频繁的垃圾回收的现象, 那么基本上我们就可以认为当前应用存在内存泄露的一个现象。当我们确定存在内存泄露以后啊,我们可以使用 gmap 工具或者从监控工具中生成对应的档部文件。然后我们可以使用内存分析工具,比如说 visualvi m a t 来分析档谱文件。这工具呢,可以帮助我们识别哪些对象占用了大量内存,并且他们是有哪些类或者现成来引用的。根据分析结果呢,我们可以仔细去审查我们的应用程序的代码,去查找可能导致内存泄露的地方。特别要注意对象引用的生命周期, 确保不再需要的时候去释放引用。定位到引发内存泄露的问题以后,我们需要根据具体的问题来进行修复,比如说使用若引用以及关闭资源,避免使用静态集合或者长生命周期的对象存储大量数据等等。总的来说,内存泄露呢,是加我应用程序中常见的一个问题, 但是我们可以通过内存分析工具审查代码,或者使用若隐用以及监控内存的使用方法。我们可以有效的诊断和解决内存泄露的问题,来提高应用程序的性能和稳定性。好啦,希望这个视频能够帮助你更深入的理 理解如何诊断和解决家网应用中的内存泄露问题。如果你觉得我今天的视频分享对你有帮助,别忘了点赞和分享,我是麦克,我们下期再见。

兄弟们,兄弟们,今天又碰到了一起非德管内存泄露啊,有的时候也挺奇怪的啊,同一类问题会高频的遇到 啊,可能这个也是叫做一种缘分吧。呃,他的话呢,是非托管内存泄露中的程序级泄露啊。今天我已经写了一篇文章,在博客源上和公众号上,大家感兴趣可以去看一下。 呃,我这个地方呢,是以视频的方式给大家简单的去说一下。像这种内存泄露的话呢,我们可以用那个 hs samary 去看一下。呃,看完了之后呢,我们再用那个一 hib 杠 low 的,我们发现有很多的程序集,有很多的模块,然后可以看到他的内存占用大概是一点一九 g 啊。 找完了之后,我们可以用那个看一下每个模块中到底有多少个类型啊。 找到了类型之后,我们就可以看到里面有很多的 jason converse 啊。对,这是我第一次遇到非同款智能泄露,和 jason conver 的有关。最终的话呢,我们就找到他这个代码啊,两张图。第一张图我们可以看到他是在那个 jason severalizer 那个里面啊,加了一个 多态性的一个扩展。这种方法一般都是在都是在那个肯飞哥 service 里面去配置的。那么那么为什么他会出现飞度管内存泄露呢?啊, 最终查下来它是因为这个地方啊,加载这个多肽性,它在那个 a p a result 这么一个协议类中,只要你调了它的对的属性,那么它就会做 a 的一次。那这个 a 的一次刚好就是 内部就是定义了程序集。所以说我调了一次,他就加载一次程序集啊,生成一次程序集,我加载我调了十次就是加载十次,调了一万次就是一万次。所以说你会生成很多的模块, 那这个就是飞度管内存泄漏。分享这些东西呢,主要就是帮助大家少走一些坑,以此为鉴吧。

哈喽,大家好,我是 solo。 从今天开始,我们来学习一个在世界范围内广受欢迎的 voui 框架。 wiltfi 是一个建立在 vots 之上的,如果你是一个 vo 开发者,那你一定要学会这个框架。相比 element ui、 iviu 等一些常用的前端 ui 库, wiltfi 是专为 vivo 深度定制的,它的颜值更高,性能更强,丰富多样的组建几乎可以满足前端开发的各种需求。我们眼见为实,来看看 wiltifa 到底长什么样子。 百度搜索 wiltfi, 在 wiltfa 官网的首页我们可以看到, wiltfifa 是一个严格基于 material degend 设计语言打造的组建库。 material degend 材料设计 语言是由谷歌提出的视觉设计语言,只在统一移动端和桌面端的使用体验和视觉效果。 莫推柔点赞,对前端 ui 的样式、动效、布局、组建等都进行了细致的规范。他定义了在前端开发中如何正确的使用阴影,在页面中如何构建更具美感的组建,甚至对使用多少像素的边框都给出了建议。 材料设计语言可以帮助我们搭建更加合理的页面结构,可显示图片如何排版字体大小和间距。 mturo 点赞定义了优雅流畅的交互效果, 导用户在石头中的视觉焦点和交互操作配法严格遵循了这一设计规范。这不仅意味着我们开发出来的应用在不同的终端都能够呈现出统一的、细致的视觉效果,而且他天生就是 响应式的。以前,如果我们想在项目中使用 lm 的 ui, 我们通常需要在入口文件引入它,然后引入样式文件,然后还要安装插件。如果想按需引入组件,那么最终的代码可能是这样的。 现在我们使用 vote five, 我们只需要一行代码, view add veyoutify wutfa 是默认按序引入的。使用 wutfa 构建项目时,我们只需要专注于写代码,其他的一切全都可以交给 wiutfa 去处理。 mutfai 由一个国外团队负责维护,但是官方提供了详细的中文文档。针对每一个组件,文档都演示了拒绝使用方法,对对应的属性和事件都有简明的解释。 mutafa 的组建库极其强 强大,一个简单的 app 的组建, rutifi 就给开发者提供了惊人的上百个接口,允许开发者灵活的定制自己的应用。使用 rutifi 构建应用,我们几乎不用写一行 css 代码,切换黑暗模式,只需要轻轻一点。这就是 rutifi 的强大之处。 wiltfifi 固然很强大,但是过于丰富的接口和灵活多变的使用方法让他存在一定的上手难度。在接下来的视频中,我会简单但恶药到讲解 wiltfire 的使用方法,带着大家快速上手这个框架。好了,我们下期见。

java 线上故障排查程序发生内存泄露如何排查? hello, 大家好,我是架构师奶爸。我们都知道 java 和 c 加加的最大区别是前者会自动收回不再使用的内存,后者需要程序员手动释放。在 c 加加中, 如果我们忘记释放内存,就会发生内存泄露。但是不要以为 jvm 帮我们回收了内存就不会出现内存泄露,程序发生内存泄露后,进程的可用内存会慢慢变少。 最后的结果就是抛出问错误。发生问错误后,可能会想到是内存不够大,于是把 xmx 参数调大,然后重启应用。这么做的结果就是过了一段时间后,问依然会出现,最后无法再调大最大堆内存了。 结果就是只能每隔一段时间重启一下应用。内存泄露的另一个可能的表现是请求的响应时间变长了,这是因为频繁发生的 gc 会暂停其他所有现成 stop the world 造成的。为了模拟这个场景, 使用了以上的程序运行参数是, x m s 二十 m x m x 二十米 x x 加 pre g c 把可用内存调小一点,并且在发生 g c 时输出信息, 运行结果如上图所示。可以看到,虽然一直在 gc, 占用的内存却越来越多,说明程序有的对象无法被回收。但是上面的程序对象都是定义在方法内的, 属于局部变量。局部变量在方法运行结果后所引用的对象在 g c 时应该被回收啊,但是 这里明显没有。为了找出到底是哪些对象没能被回收,我们加上运行参数, x x h e a p dump on out of memory error x x h e a p dump half he been 意思是发生用时把堆内存信息 dump 出来 am 运行程序直至异常, 于是得到 hip down 文件。然后我们借助 equips the mat 插件来分析,如果没有安装,需要先安装,然后 file open hip down, 然后选择刚才 dump 出来的文件,选择 lick suspects met 会列出所有可能发生内存泄露的对象。 可以看到居然有两万一千二百六十个 threat 对象,三千三百八十六个 threat poor executor 对象。如果你去看一下 java util concurrent threat poor executor 的原码,可以发现县城池为了附用 线程会不断的等待新的任务,线程也不会回收,需要调用其 shut down 方法才能让线程池执行完任务后停止。其实线程池定义成局部变量,好的做法是设置成单立,上面只是其中一种处理方法。在线上的应用, 内存往往会设置的很大,这样发声用再把内存快照当出来的文件就会很大,可能大到在本地的电脑中已经无法分析了, 因为内存不足够打开这个 down 文件。这里介绍另一种处理办法,一、用 j p s 定位到晋城号,因为已经知道了是哪个应用发生了 on, 这样可以直接用 j p s 找到进程号。二、用 dot 分析 g c 活动情况 dot 是一个统计 java 进程内存使用情况和 g c 活动的工具,参数可以有很多 多,可以通过 dot help 查看所有参数以及含义。上面的命令意思是输出 g c 的情况,输出时间,每八行输出一个行透信息,统计的进程号是二四八三六,每一千毫秒 输出一次信息。输出信息是 time, step 是距离 j v m。 启动的时间。 s 零 s e e 是新生代的两个 survivor 和 eden, o 是老年代区, m 是 mates space c c s 使用压缩比例。 y g c 和 y g c t 分别是新生态 g c 的次数和时间。 f g c 和 f g c t 分别是老年代 g c 的次数和时间。 g c t 是 g c 的总时间。虽然发生了 g c, 但是老年代内存占用率根本没下降,说明有的对象没法被回收,当 也不排除这些对象真的是有用。三、用 j m a p 工具 dump 出内存快照 j m a p 可以把指定 java 进程的内存快照 dump 出来,效果和第一种处理办法一样,不同的是他不用 dom one 就可以做到,而且 dump 出来的快照也会小很多, 这时会得到 even 的内存快照文件,然后就可以用 eclipse 来分析了。想了解更多 java 架构师岗位知识,请关注我,架构师奶爸共同筑基 java 架构师。

今天周末哈,我们分享一个问题,也是解决解决就是在直播间经常问到的这个问题,就是内存溢出的情况,内存溢出的话, 嗯,基本上是由于就是说要么就是我们呃前期在资源规划的时候使用的内存啊,就是申请的内存太小。另外一个的话就是说申请内存啊,就是能满足一般情况下的一个应用。关键是在我们处理呃这种大量数据,或者是 或者是一一定场景下,比如说像是报表生成啊,呃, etr 当中的数据处理或者是文件生成啊,这样的话要经过大量的就是要需要,就是说组装成大量的数据,或者是要抽取大量的数据的时候,都有可能是发生内存溢出的情况,那在我们写代码的时候 也是我们做开发经常关注的,因为在实现这些场景架的时候,场景的时候,那我们一定是要注意一下,我们先去规划好啊,设设计好怎么样去实现 啊?尽量的避免大量,就是变量的生成或者是循环套循环这种情况,一般这种情况下都很很可能会发生内存溢出。

这就是我坚持的动力,我看今天群里反馈了一些问题,你改了没?没,还没来得及改那些。那都是些小的,一晃没有大的一些罢了。我今天改啥?就是现在就是, 呃,性能有点,媒体稍微人多一点啊,这个 cpo 以及内存就会飙升,所以我在排查代码,看他们男女有没有内存泄漏。今天我利用用这个 阿里这个诺基亚的新闻平台在这飞行看内存就占了百分之九十八点三,我在排查。排查在吗?嗯,那完了我把群里那些问题整理一下,你有时间一起改吧。 哎,行行,我,我先把又先把这个搞完吧,大家能够流畅的用。嗯,没看啊,今今天到现在又一千零二 二十三个,我觉得现在每一天稳稳当当的在一切以上。可以可以可以可以,加油,这就是我坚持的动力,哈哈哈。

hello, everybody this is john from the future i'm doing a little quick edit beginning of this video so i can include this little announcement i'm really excited about this i hope you guys are as well the past couple days i just spent some time building creating developing a tri hack me room so i'm very very excited about this i kind of have my own custom one out there it is being released tomorrow may 20th sometime around that hopefully you can keep an eye out for it and check it but pkil is a new run that i'm very excited about pkil peak hil and i impleased with it it sounds like everyone that played tested it had a lot of fun so i'm really looking forward to it i hope you guys go check it out and i'm so so grateful for your support thanks! so much hope you guys enjoyed the video take care hello everyone! my name is john hammond and welcome back to another tri hack me video in this video i want to be taking a look at the cod caper room it is a free room so you do not need to be subscribed to access it it says it is a guided room taking use your infiltrating and exploiting a linux system so i have it deployed already i'm joined this room i've got a little ip address setup and created for me the background on this and this is a good guided one it explains hello my name is whatever that is i've come here to put in a request to get my fish back exciting looks like he's banned from something etc etc it looks like we need some basic pen testing allerge and we're not going to be going through every tool in detail, so let's just jump in okay cool! we've read that let me move over and make a directory for the cod caper caper and let's get a little read me going let's see where's my sublime text okay so the cod caper code caper that's also cool cake you know i can't type i don't know why you guys even follow i don't know i don't know why you even watch this this series this youtube channel i don't know if you can hear that ambulance driving by, but that's total getting in the way task one no answer need it task two i'm just i just like to have some documentation sorry i know it's stupid host numeration looks like we want to go ahead and run end map okay so i should probably start that up let's create an end map directory let's go ahead and get that ip address in the scope for our terminal and let's fire that off end map initial on the ip address okay i should be able to ping him just fine i believe he's up already yep okay cool so let's let that go how many ports are open on the target machine while that's scanning let's just kind of throw these in our little right up here i like to do this even if it's just crappy because hey you might be able to just kind of throw this up on github or medium and be like yo this is my right up of this thing that i did and you can put in as much as you want to in this i just like to slap in like n map skin results if it's on a separa file or any of those things, but i just like to have an extra copy of all of these answers when i go back to them, this does discuss a little bit of n map showcasing some of the arguments and switches and parameters you can give to it i think i've covered n map a lot and a lot of my different videos and i've used it all the time so that tacksc script that i always throw in will run default scripts on the port the tack capital a will go into aggressive mode that will try and get it as much information as possible anyway, let's go see what we've got here? only two ports? it seems okay so 22 and 18 there are two ports on that box let's go ahead and slap that into our answer what is the http title of the web server? so with that default scripts taksc it did already track that down it's just the apache 2 who bun two default page? so let's go ahead and copy that string and slap that in as the answer and we can keep note of that here what's the version of the ssh server? open ssh seemingly ubuntu throw that guy in i don't think we need the parenthetic hall okay that looks like more of the format that tri hack me needs did i throw that in the wrong spot what is the version of this? a safe service? oh, oh, i totally missed a box here you guys should have told me? i should have just screamed at your computer screen and obviously i would have heard it version of the web server do we have a version? yes, we do okay still output from n map slap that guy in what format does that need to be in oh looks like that as the server header is what's asking for maybe yeah okay! cool! i like that try hackley gives you those little asterisks and helps you showcase what you're really trying to cement? so because we know that this is running apache or it has a web service on here we can go ahead and kind of brute force directories or some files or content that might be available on that website, they actually give us a link here so let's go ahead and download that for the word list that we will use to go ahead and pull down or try and hammer the website to see if there is any actually interesting text files that might be potentially there or php files or directories or anything that we'd like to look for gobuster is an awesome tool to do that in so i'm going to go ahead and fire that up i'll use gobuster attack you on httprip address i'll use the word list of big and i'll supply some extensions here because they kind of suggested it sh text cgi js ess html maybe some python files whatever we might happen to want to search for so we got what is the name of the important file on the server? hmm i don't know task three just slapping these answers and questions and for good documentation what is happening? what is going on? a lot of nonsense in here failing to parse some stuff that is not what i expected okay is it adding more to that no it is yeah definitely is maybe i don't need to look for all of those extensions maybe let's just look for php text and html quality content i have no idea what that could be because it's a long long file name and obviously a three little one could be php could be text let's go take a look at that web server though let's go see what this website actually has to be displayed on it for us at the fall page that's why we're running go buster? i'm a fool what is going on guys? what is all this all right? let me pause this to figure this out okay so i realized the error and i realized kind of my mistake i'll show you just kind of my troubleshooting process i redirected the output or the standard error of gobuster to devnel and just rep for 200 so i would only be able to see things that would have a successful return and then i was like what is that big list actually returning for me and i realized oh it is an html file it is not a wordless so the fact that i use w get probably kind of bored to that so let's go ahead and re download that and ideally that will work better now okay, it's not an actual text file that's that's exactly why now that's moved to downloads? let's copy that over here let's move our downloads big dot text into this guy is he still going no, he's good what do you mean? it's not downloaded where'd you put up? whatever oh i put in my home directory google chrome how could you do this to me all right? so now let's fire that back up and hopefully that should work some learnings, some mistakes and i was trying to be nice and clever by was using a simple of w get that big dot text was mixed leading i thought they were giving me a real text file not a github link i guess i should have looked let's blame me so what is the potential interesting stuff in here dot ht password seems kind of peculiar hd passer dot text might be useful all php probably won't be able to read dot ht access is all accessible that one in here how about ht access dot php? nope okay i guess we're still gonna be waiting can i access those can we go see what those have let's go back to that let's go back to that website see what we got? there's our flat page let's check out ht access dot text i'm not a lot of you those i probably should have known that by looking at the status we'll see them by i'll keep waiting for go bus to finish that up okay so now i see an administrator php that sounds like the right number of characters and is probably an interesting page so let's try that guy looks good all right let's throw him in our notes here and let's keep moving on web exploitation the admin page seems to give his login form and situations like this it's always worth about to check for the low hanging fruit case of login forms, one of the first things to check for is sql injection so they actually showcase sequel map here and they suggest using the tacku argument to specify the url dumping stuff with forms or just grab everything from the database so do i actually have sequel map installs here i don't think i've used it in a bit sick well map nope all right let's fire that up it's probably not the best to take it from repositories it would be a much better idea to pull it from the github repository but i just kind of want to move through with some speed here because i think we've dottled enough in this video so all right cool sequel map why do? i keep doing that now that you're in my path great! let's fire that up the ip address is this guy so let's fire that in sequel map attack you let's go take a look at that page first and see what it actually looks like administrator phb okay it just needs a login but it's probably vulnerable to sequel injection let's try sequel light nope let's try regular sequel try again one equals one try again does that need to be in the pat okay, let's just run our stinkin sql map and try to let's use tag tag form and that needs to be on the administrator dot php using tag tag form because there isn't an argument through get that we're passing this is all through post so it won't be using anything after like a question mark var equals value in here it's going to be determining it on the form on the page here because it's a post method go yep just that form do it do it fill with random data figure it out looks like the back and database is my sequel do you want to skip payloads? my faces in the way yeah, we want to skip payloads we don't need to do that stuff yes, go ahead and continue with all the tests sequel map likes to be a very inquisitive it's very very curious let's see if that gets any results for us okay sequel maps seem to find some things where it's thinking a post primer is injectable but it's asking do you want to try with random characters rather than no values and i say yes that's totally fine just keep beating it up and maybe you'll track down and potential injection great now figured out that username variable is vulnerable and we can inject into it do you want to test? any others i'm going to say no here and then you want to exploit this equal injection i'm going to say yes and now we have that kind of payload to save and cash so it's equal injection can use it later i do want to specify the tac tac because that will dump everything from the database as it said not tack tack or just a regular height fent just attack grabs just about everything from the database let's grab it all let's see what you can get? you will probably need to go select and enter everything that already found test primer don't need to be injectable you already found this you already figured this out hate doing this because when i use tag tac form, it doesn't particularly have an idea what? i'm referring to let's just try and use tac data is that a thing let's check out the man page for sql map data, string data to be sent through post so i'll use tactic data and username equals so we can supply that field i'm going to use an ampersand here password equals because i'm using the ampersand bash might interpret that as me trying to background a job so i'm gonna use single quotes here and let's see if that gets the exploit in okay, so now i can use tack a and start to leak out everything so that tack a as was suggested in the texture will retrieve some password do you want to store hatches to temporary file for eventual eventual further processing with the database tools yeah that's fine go ahead and perform a dictionary based attack on those password hashes um feel free to do with an default dictionary no, we don't need to use password suffixes let's see if it tracks anything down, so maybe this is a hash for root oh, looks like it cracks some passwords here okay roots password is simply root and maybe that will work maybe that is the answer okay, so it's dumping out all the privileges wow there's a lot of stuff in here i've never actually used hack a for sequel math that's kind of cool is his password oh it's not just straight room we even know the admin password how many forms of sequel injection is a form vulnerable to we found three for the time based air the blind air the air based injection time based injection, air based injection and blind injection it's retreating a lot of stuff i don't know if i want all of those can we just dump the database's name or maybe it is maybe it's really helpful i'll just leave it on and we'll pause you know what that is taking a long long time and it's getting some useless things that i don't care about so i am gonna break that and let's just use tack tack dbs to leak out the databases information schema okay i'd already found some of these let's just use tac tac d users and then oh sorry tac d users and then tac tac tables to dump out the tables there we go so users okay now i can specify tac t for users and let's dump that out use the name password there we go okay so use the name pingu dad and password is secret pass so let's slap that in and pingu dad pingu dad wow all right! i'm going to steal that syntax and just kind of slap it in here for our notes i'll see actually also keep track of that command i'll copy and paste that guy there we go and i guess i won't bother filling those in let's do some command execution it seems we've gained the ability to run command since it's an lpc i should sell of user accountants when if he test commands and try and get asked probably, just was going to allow us some communication on like some ability to actually run commands on the admin panel now that we have logging credentials we could probably do that that's totally fine okay so if we want to run commands, we could just run ls and kind of see some things around here, but we could try and get a shell so what i'm gonna do is i'm actually just going to fire up greek and use my poor man's pen test because it looks like if we have that netcat on the box, we can slap in a netcat reverse shell and then go ahead and get that connectivity so now that that is accessible for us let's try and see if we have python, python tax c print please sub sun i suck at typing that works so let's go ahead and stabilize this shell and now we should have a usable utility okay what is it asking for following this? how many files are in the current directory? we saw three here do i still have an account let's cat out its set for a password and see pingu he exists so let's say yes i'm assuming that's it because it's three letters yep that's fine what is my ssh password? well, let's go into home and he has a home directory so let's go check that out is there anything in here there is nano that's a directory it also has a cessation here what is sxh password? would it be he doesn't have any bash history geb history which is kind of interesting maybe he has something in nano ls techulate nothing in here, so no history in that well, we could go ahead and get his ssh key maybe that has a password set on it maybe that's what it's referring to let's cut out that idrsa key so we have his private key and let's go ahead and create a directory to actually iraq with that that put me in my cough directory because that is where wake tends to live so let's say pingu id rsa slap that in make that something that ssh is willing to use and let's actually grab our ip address because i'm in a new shell so i can ssh tack i that guy at pingu at the ip address log me in please yep that's totally fine and he needs a password that's not secret pass again is it could we brute force that with hydra what am i missing why do i not see his password? well if i go back and read the prompt here assuming my father was a modified to go remope see i should still have a hidden password sword somewhere we don't know where it is so we could find it with find search refiles at a specific user owns so let's go to the root director and let's do find directory user tack user pingu and let's force all of that bad noise to dev no and let's see if he has any files that he owns that might take a little bit of time to come through, no cash is that it nope be weird to see it in gdb history whatever, let's just freaking get linpies in here, because i'm not seeing it in that now that we have limpies let's mark that as executable run it and t that to lin log so we have some saved output let's look for some interesting things so that my sequel database is in there papa that's the other user those are all of my sequel strings we're able to determine already that's all our same private ssh key yep we've got that but we need to know his password maybe there is some stuff that papa owns that is interesting oh bar backups shadow dot back let's take a look at with that guys i can't read that okay okay after a good while of looking around i think i found it ended up finding it manually in the var directory with a little hidden folder and hidden and there is a pass file there and is a ping you up ping you so that is the password there we go i guess i had not found that because it is not owned by pingu it is owned by the wwda user which i guess like maybe i'm just stupid maybe i just didn't think of that but obviously if we were to go run our fine command again and i tried to add some of the arguments like hey why can i find this apparently the user is not pingu it is dobbed of data so let me this guy there we go interesting okay that's that now we could totally ssh in that machine so let's ssh tack i that pingu idrsa to that pingu user on the ip address and checking that password again just to jump in here there we go now we are logged in via ssh so it's telling me to go ahead and do some linenum i would do the same with limpies so that should still be executable we can go ahead and run it one more time it's apparently looking for interesting suid binaries maybe i had not found it or it just didn't look for it due to checking passwords or there might be some peculiar ones in here suid your group chfn looks like it has an interesting path with a long name in the middle secret route that one that i found earlier i don't know why i missed that let me go ahead and add some more time to this because it has taken me way too long to go track through this off secret route is what we're looking for good looks like this is a binary can i go check that out can i hop over there let's tack la file root i can execute it it is a binary able to grab the source code from my dad's flash drive it has a shell function interestingly enough that will go ahead and cat out the bar backup shadow back which looks like a backup of its set for shadow and read an input okay? so this looks like a classic buffer overflow so it's going through in the triac me walk through explaining this is what you could do with pone debug or some added plug ins for gdb i've showcased a couple of command line linux buffer overflow stuff before so what i'll end up? doing is actually just using redelf to go ahead and determine the address of that shell function and then doing kind of their trick to exploit manually using python and print all that out it looks like they have python too in here so that should be accessible if we were to do a python three let me check if python three is in here, it is okay great so i'll use python three in that case hopefully get that right do we have read elf? we do so let's go ahead and read elf the symbols on that binary here and the shell function has this address so if we were to use cyclic, which i don't know if we have okay, we do because it gave us pone tools in here nice, we're gonna check for some versions of pone tools which this machine probably doesn't have internet, so that won't work we totally don't have metasplate, but we can go ahead and use pone cyclic on our own machine so let's get cyclic 50 and let's throw that at the binary but dub dub dub shell i guess i don't need anymore so let's echo tack any that cyclic pattern into root and see where it crashes we get a segmentation fault i'm gonna run d message to go see where that's at and then i'll go ahead and cyclic i think it's tack l to look up i think it needs a zero x in here or maybe it doesn't okay step pattern must be four bites so it totally does maybe it's tack q or tack p tack l hello oh that might be winning because it's doing some python three things and maybe that is specific to python two okay so now if i use that look up and i'll use zero x here forty four is the offset which is good because that matches kind of what the tri hack me room was walking us through so we know our read elf tack s on root with the shell function oh, grip shell so that is the address that we need so python two let's go ahead and print out nonsense 44 times to get to the offset where we can go ahead and grab the instruction pointer and now let's import struct over at the beginning of that, so we can struct pack and make that and some bytes we could supply is 0x to include that close that and that so now we have the raw bites and we'll go ahead and pass that to the root function which we'll cat out the backup file for us there we go we could do that with pone tools just as easily and that's the next section that they discuss they actually offer the script here where they're doing that they use pone tools to create a process grab the l file so it has the binary and search for the actual address of the shell function and they do a really cool technique i actually haven't seen that fit function before it'll fit 44 characters and then grab the shell function right after it so that's kind of neat and it just sends it long and makes it makes it interactive so same sort of technique same thing just some python pone tools access and there we go mark that as complete and now we need to go ahead and crack that hash so they're using hash cat i think i'm just gonna go ahead and use john there we have papa here as his string so i'll go back to my host and i'll just say subble shadow i'll pass that guy in and i'll use opt draw on the ripper run john tactic word list equals opt rock you dot text and i'll run it on that shadow file okay now i found the password there it is postman so back to our shell we could se you to papa enter postman as our password now we are papa and submit postman here what? what? oh what is the root password? i'm sorry let's not papa what can papa run? can he escalate our privileges? no, we can't sudo well what else? could we potentially do then maybe in that output? we actually had a root password could we crack that let's include that guy here run that one more time and let's see if john the ripper could crack that i guess i'll go ahead and go check out if there's any routes for privilege escalation with the papa user well that's going okay actually, john the ripper was able to go ahead and crack that root password and that answer is love to fish there we go now we could just go ahead and switch user into root use his password here and is there anything in the root directory nope some new root flag to go into looks like that's just a simple thank you and says great we completed the room so okay that was that wow that took a little bit of time i was fumbling a lot on that one i hope you guys enjoyed that was kind of cool to get a little bit of binary exploitation at least just a simple classic buffer overflow and they do a really good job of showcasing the different waves to go about this pond debug is kind of cool giving you the source code you can understand where that vulnerability comes from and being able to go determine okay what's the address and where can we track down all of that information to build that buffer overflow in that classic exploit okay that's that that's all i wanted to cover thank you guys so much for watching if you did like this video, please do hit that like button comment do the youtube algorithm stuff please subscribe and love to see you guys love seeing the discord server let's see on patreon paypal linkedin facebook twitter instagram all those other things thank you bye。