linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: gaoqiang <gaoqiangscut@gmail.com>
To: "linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: bug for stack ?
Date: Tue, 17 Apr 2012 17:20:20 +0800	[thread overview]
Message-ID: <op.wcwj76p5n27o5l@gaoqiang-d1.corp.qihoo.net> (raw)


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>

             reply	other threads:[~2012-04-17  9:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17  9:20 gaoqiang [this message]
2012-04-18 15:52 ` Rik van Riel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=op.wcwj76p5n27o5l@gaoqiang-d1.corp.qihoo.net \
    --to=gaoqiangscut@gmail.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox