内存泄露
来源:互联网 发布:java snmp编程 编辑:程序博客网 时间:2024/04/26 17:47
#include <windows.h>
#include <time.h>
#include <math.h>
#include <conio.h>
#include <iostream>
using namespace std;
void GetMemory(char **p, int num)
{
*p = (char *)malloc(num);
}
void main(void)
{
char *str = NULL;
while(1)
{
GetMemory(&str, 100000);
strcpy(str, "hello");
printf(str);
free(str);//如果此处不释放内存,则每次调用函数都产生内存块
//从而使内存泄露,最后导致内存溢出
}
}
#include <time.h>
#include <math.h>
#include <conio.h>
#include <iostream>
using namespace std;
void GetMemory(char **p, int num)
{
*p = (char *)malloc(num);
}
void main(void)
{
char *str = NULL;
while(1)
{
GetMemory(&str, 100000);
strcpy(str, "hello");
printf(str);
free(str);//如果此处不释放内存,则每次调用函数都产生内存块
//从而使内存泄露,最后导致内存溢出
}
}
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 内存泄露
- 心得10--request介绍和案例分析、请求重定向和请求转发的区别
- Access restriction: The type FileURLConnection is not accessible due to restriction
- request
- 心得11--案例分析request.getparameter()方法的用法及请求乱码处理、分配器方法
- PoolManger模式(二)
- 内存泄露
- 心得12--MVC设计模式
- 《疯狂的程序员》二
- 程序员不容易程序员不简单,程序员笑话你懂得
- CodeIgniter 入门
- SQLServser基本语句
- Java中用split()函数进行分割字符串
- 《AS3 Expert》_2:FB与FD代码智能提示的隐匿陷阱
- Java联网五子棋(附源码)