linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* bug for stack ?
@ 2012-04-17  9:20 gaoqiang
  2012-04-18 15:52 ` Rik van Riel
  0 siblings, 1 reply; 2+ messages in thread
From: gaoqiang @ 2012-04-17  9:20 UTC (permalink / raw)
  To: linux-mm@kvack.org


memory allocated for process stack seems never to be freed by the kernel..


on a vmware machine with about 768m memory, run the following program.when
printing "run over", run another case of the following program. oom-killer
trigered, which is not so reasonable.


#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <alloca.h>
void*stack=NULL;
const long water_mark=512*1024*1024;
void func()
{
	int p=0;
	if((long)stack-(long)&p> water_mark)
	{
		printf("hit\n");
	}
	else
	{
		func();
	}
	return;
}
int main()
{
	struct rlimit limit;
	limit.rlim_cur=1024*1024*1024*1.5;
	limit.rlim_max=1024*1024*1024*1.5;
	setrlimit(RLIMIT_STACK,&limit);
	int a=0;
	stack=&a;
	printf("run\n");
	//getchar();
	func();
	printf("run over\n");
	getchar();
	return 0;
}

-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-18 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-17  9:20 bug for stack ? gaoqiang
2012-04-18 15:52 ` Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).