C语言malloc申请内存不释放的后果

C语言,用malloc动态申请内存,不free,电脑会死机吗

代码

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void malloc_no_free()
{
	char *p;
	p=(char*)malloc(10000000);
	strcpy(p, "gfhfjhkjhfkkhskjfhksh\n");
	puts(p);
}
int main()
{
	int i;
	for (i=0;;i++)
	{
		printf("第%d次\n ", i);
		malloc_no_free();
	}
	system("pause");
}

查看任务管理器

到第209次,程序就自动关闭了,不知道为什么?内存占用如图
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/sinat_42483341/article/details/86490619
今日推荐