死循环用途,检查代码中内存泄漏
死循环就是一直循环下去, 如 while(true)??? for(;;),一般正常编程的时候很少会用到。
都知道死循环是非常不好的,会让程序崩溃。哪死循环真的没有用途吗?
其时死循环也有它自己的用途,要看用来做什么事,比如检查代码内存泄漏(一般来讲就是new了内存,没有delete)。死循环、内存泄漏在编程中都是非常讨厌的,但两个放到一起又可以变的不一样,也许这就是传说中的以毒攻毒。
下面讲下如何实现:
1.将要测试的代码封装成一个函数,
2.用死循环while(true)调用封装好的函数,编译运行
3.打开资源管理器,如有内存泄漏,内存占用将一直长大
具体实现代码:
注:内存泄漏这类问题在C/C++中是比较常见的问题,它不像java/C#,因为C/C++有指针就会有这问题,指针是一把利剑。
Superb advice. With thanks. fluconazole 200 mg
You mentioned that wonderfully. highest rated canadian pharmacies
You actually revealed it exceptionally well! viagra without a doctor prescription 200mg
This is nicely put. . viagra prank
This is nicely expressed! ! https://viagrapycharm.com/
Many thanks! Good information. canadian pharmacies shipping to usa
Thanks, I appreciate it! canada online pharmacies
You stated it really well! generic canadian viagra without presription
You said that exceptionally well. canadian pharmaceuticals online
Fantastic info, Regards! canadian online pharmacies
Info nicely applied.. canadian online pharmacies
Thanks, Helpful information. celebrex 200 mg
Fantastic data. Cheers. buy generic viagra
With thanks. Very good information. northwest pharmacy/com
Fantastic content, With thanks! viagra without a doctors prescription
Amazing information. Appreciate it. canadian pharcharmy
Information certainly applied!. Discount Super Cialis
Awesome information. Thanks a lot! canadian pharmacies shipping to usa
Thanks! Numerous content.
kratom capsules
Really many of excellent advice! Kamagra Pills Review