All of lore.kernel.org
 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


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

* Re: bug for stack ?
  2012-04-17  9:20 bug for stack ? gaoqiang
@ 2012-04-18 15:52 ` Rik van Riel
  0 siblings, 0 replies; 2+ messages in thread
From: Rik van Riel @ 2012-04-18 15:52 UTC (permalink / raw)
  To: gaoqiang; +Cc: linux-mm

On 04/17/2012 05:20 AM, gaoqiang wrote:
>
> memory allocated for process stack seems never to be freed by the kernel..

It should get freed on process exit.

> 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.

You start your second run before your first run
has exited.  The system does not have enough
memory for two such runs, so you run out of
memory.

--
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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.