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

怎么做网站镜像seo排名培训公司

怎么做网站镜像,seo排名培训公司,做汽车商城网站,广告推广平台代理内存泄漏是指程序动态分配的内存未能及时释放#xff0c;导致系统内存逐渐耗尽#xff0c;最终可能造成程序崩溃或性能下降。在C中#xff0c;内存泄漏通常发生在使用new或malloc等分配内存的操作时#xff0c;但没有正确地使用delete或free来释放这块内存。 在日常开发过程…   内存泄漏是指程序动态分配的内存未能及时释放导致系统内存逐渐耗尽最终可能造成程序崩溃或性能下降。在C中内存泄漏通常发生在使用new或malloc等分配内存的操作时但没有正确地使用delete或free来释放这块内存。 在日常开发过程中为了避免内存泄露一般都用智能指针去自动管理内存避免忘记释放。 1.内存泄露动态分析工具——Valgrind Valgrind是运行在linux上的程序分析工具它包含很多小工具 memcheck(内存泄露检查工具)等 1.1 安装Valgrind 下载链接https://valgrind.org/downloads/current.html#current 1.2 Valgrind简单上手和分析 参考:Linux 性能分析valgrind一之memcheck使用 命令(以下程序均可以使用此命令) valgrind --log-filevalgrind.log --toolmemcheck --leak-checkfull --show-leak-kindsall ./your_program # --log-file: 报告文件名。如果没有指定输出到stderr # --toolmemcheck: 指定Valgrind使用的工具Valgrind是一个工具集包括Memcheck、Cachegrind、Callgrind等多个工具memcheck是缺省项。 # --leak-check: 指定如何报告内存泄漏memcheck能检查多种内存使用错误内存泄漏是其中常见的一种可选值有: # - no 不报告 # - summary 显示简要信息有多少个内存泄漏。summary是缺省值。 # - yes 和 full 显示每个泄漏的内存在哪里分配。 # --show-leak-kinds: 指定显示内存泄漏的类型的组合。类型包括definite, indirect, possible,reachable。也可以指定all或none。[缺省值](https://www.zhihu.com/search?q缺省值search_sourceEntityhybrid_search_sourceEntityhybrid_search_extra{sourceType%3Aarticle%2CsourceId%3A92074597})是definite,possible。 运行一段时间后想停止进程不要kill掉需要ctrl c来结束输出的log会在上述命令中的valgrind.log中。程序1C程序使用未初始化的内存 #include stdio.h #include stdlib.h int main(void) {char *p; char c *p; printf(\n [%c]\n,c); return 0; }Valgrind重点结果信息使用未初始化的变量无效的读( 读取没有分配地址空间的区域数据 ) 73374 Use of uninitialised value of size 8 73374 at 0x400513: main (in /home/bossdog/3Growup/valgrind/test1/a.exe) 73374 73374 Invalid read of size 1 73374 at 0x400513: main (in /home/bossdog/3Growup/valgrind/test1/a.exe) 73374 Address 0x0 is not stackd, mallocd or (recently) freed程序2C程序在内存被释放后进行读/写 #include stdio.h #include stdlib.h int main(void) {char *p malloc(1);*p a; char c *p; printf(\n [%c]\n,c); free(p);c *p;return 0; }Valgrind重点结果信息: 74181 Invalid read of size 1 74181 at 0x4005E3: main (in /home/bossdog/3Growup/valgrind/test1/a.exe) 74181 Address 0x520a040 is 0 bytes inside a block of size 1 freed 74181 at 0x4C3195F: free (vg_replace_malloc.c:872) 74181 by 0x4005DE: main (in /home/bossdog/3Growup/valgrind/test1/a.exe) 74181 Block was allocd at 74181 at 0x4C2F075: malloc (vg_replace_malloc.c:381) 74181 by 0x4005A8: main (in /home/bossdog/3Growup/valgrind/test1/a.exe)程序3C程序: 内存泄露 #include stdio.h #include stdlib.h int main(void) {char *p malloc(1);*p a; char c *p; printf(\n [%c]\n,c); return 0; }Valgrind重点结果信息直接泄露 74814 1 bytes in 1 blocks are definitely lost in loss record 1 of 1 74814 at 0x4C2F075: malloc (vg_replace_malloc.c:381) 74814 by 0x400558: main (in /home/bossdog/3Growup/valgrind/test1/a.exe)程序4C程序不匹配使用malloc free 和 new delete #include stdio.h #include stdlib.h #includeiostream int main(void) {char *p (char*)malloc(1);*p a; char c *p; printf(\n [%c]\n,c);delete p;return 0; }Valgrind重点结果信息: 75341 by 0x400683: main (in /home/bossdog/3Growup/valgrind/test1/a.exe) 75341 Address 0x5b20c80 is 0 bytes inside a block of size 1 allocd 75341 at 0x4C2F075: malloc (vg_replace_malloc.c:381) 75341 by 0x400648: main (in /home/bossdog/3Growup/valgrind/test1/a.exe)程序5C程序 两次释放内存 #include stdio.h #include stdlib.h int main(void) {char *p (char*)malloc(1);*p a; char c *p;printf(\n [%c]\n,c);free(p);free(p);return 0; }Valgrind重点结果信息: 76126 Invalid free() / delete / delete[] / realloc() 76126 at 0x4C3195F: free (vg_replace_malloc.c:872) 76126 by 0x4005EA: main (in /home/bossdog/3Growup/valgrind/test1/a.exe) 76126 Address 0x520a040 is 0 bytes inside a block of size 1 freed 76126 at 0x4C3195F: free (vg_replace_malloc.c:872) 76126 by 0x4005DE: main (in /home/bossdog/3Growup/valgrind/test1/a.exe) 76126 Block was allocd at 76126 at 0x4C2F075: malloc (vg_replace_malloc.c:381) 76126 by 0x4005A8: main (in /home/bossdog/3Growup/valgrind/test1/a.exe)1.3 官方手册 官方手册 2.实际问题分析 struct image_u8 {const int32_t width;const int32_t height;const int32_t stride;uint8_t *buf; };std::shared_ptrimage_u8 image;image.reset(new image_u8({ frame_out.stFrameInfo.nWidth,frame_out.stFrameInfo.nHeight,frame_out.stFrameInfo.nWidth,new uint8_t[frame_out.stFrameInfo.nWidth * frame_out.stFrameInfo.nHeight * sizeof(uint8_t)] }));image.reset();std::shared_ptr 会自动管理 image_u8对象的生命周期但是它不会管理 buf即 uint8_t* 类型的指针所指向的内存。 当执行image.reset();之后image指针被释放重置了但是指针所指向的指针即 uint8_t*没有被释放造成了内存泄露。 记录 二级指针被释放时不会自动释放一级指针中所指向的内存。 参考https://blog.csdn.net/weixin_44477424/article/details/136417250
http://www.hkea.cn/news/14389658/

相关文章:

  • 专业制作企业网站wordpress 迁移 ngix
  • 微网站需要备案吗俄文网站推广
  • 网站建设应列支什么科目网站建设 价格
  • 青岛的网站建设临沂做网站企业
  • 七牛云存储可以做网站免费logo图片在线制作
  • 自适应型网站建设方案wordpress站外链接页面
  • 宝安网站制作哪里好别墅建筑设计说明
  • 洛阳建设银行网站开发购物网站
  • 张家港做淘宝网站网站权重等级
  • 湖南高端网站制wordpress+团购
  • 接网站建设_网站设计咸阳公司网站建设
  • 温州网站建设icp备专业教学资源库网站建设工作
  • 响应式设计网站案例银川网站建设是什么
  • 网站开发软硬件环境是指什么团购网站seo
  • 网站模板带有sql后台下载做博客网站最好用什么系统
  • 镇江市住房城乡建设局网站中国交通建设集团有限公司是央企
  • 数据网站建设中学生网站设计下载
  • 山东建设信息网站注册网站会有哪些风险
  • 网站的登录注册页面怎么做的wordpress 网址全部变成ip
  • 万能网站浏览器apicloud开发教程
  • 江苏省住房城乡建设部网站合肥app开发费用
  • 简历模板网站免费wordpress文章不显示标题
  • 网站诊断网站seo诊断做网站的公司怎样收费
  • 西安网站建设昆奇网站api怎么做的
  • 婚庆公司网站怎么做手机单页网站教程
  • 网站怎么做 流程图wordpress用户密码 破解
  • 机关单位网站建设申请湖南做门户网站的公司
  • 网站建设设计问卷公司网站注意事项
  • 答题网站开发wordpress页面和自定义链接地址
  • 宿州做网站分销系统php开源