* 2.4.22 O_DIRECT memory leak?!?
@ 2003-10-08 16:09 Magnus Andersson
2003-10-09 19:37 ` Marcelo Tosatti
0 siblings, 1 reply; 3+ messages in thread
From: Magnus Andersson @ 2003-10-08 16:09 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 401 bytes --]
Hello!
If I open one file a lot of times using the flag O_DIRECT,
memory seems to be be lost and never given back to the system.
This is happening on some kernels, see below for which ones I tried.
Attached program will produce this behavior, also attached
is the output from vmstat while running the program.
Affected:
2.4.22
2.4.22-ac4
2.4.23-pre6
Not affected:
2.4.22-aa1
2.6.0-test6
/Magnus
[-- Attachment #2: open_odirect.c --]
[-- Type: text/plain, Size: 531 bytes --]
#define _GNU_SOURCE
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#define NFDS 1000
#define ERR(args...) fprintf(stderr, args);
int main()
{
int i, fds[NFDS];
for(i = 0; i < NFDS; i++) {
if((fds[i] = open("./file", O_RDONLY | O_DIRECT)) < 0) {
ERR("main(): open(): %s\n", strerror(errno));
exit(1);
}
}
for(i = 0; i < NFDS; i++) {
if(close(fds[i]) < 0) {
ERR("main(): close(): %s\n", strerror(errno));
exit(1);
}
}
}
[-- Attachment #3: vmstat.output --]
[-- Type: text/plain, Size: 955 bytes --]
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 0 498324 916 7632 0 0 54 9 109 22 1 19 80 0
0 0 0 498320 916 7632 0 0 0 0 101 2 0 0 100 0
0 0 0 498320 916 7632 0 0 0 0 101 2 0 0 100 0
0 0 0 498320 916 7632 0 0 0 0 101 2 0 0 100 0
0 0 0 498320 916 7632 0 0 0 0 101 2 0 0 100 0
1 0 0 485072 916 7632 0 0 0 0 104 11 0 6 94 0
0 0 0 386276 916 7632 0 0 0 0 116 7 0 41 59 0
0 0 0 386276 916 7632 0 0 0 0 101 2 0 0 100 0
0 0 0 386276 916 7632 0 0 0 0 101 2 0 0 100 0
0 0 0 386276 916 7632 0 0 0 0 101 2 0 0 100 0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 2.4.22 O_DIRECT memory leak?!?
2003-10-08 16:09 2.4.22 O_DIRECT memory leak?!? Magnus Andersson
@ 2003-10-09 19:37 ` Marcelo Tosatti
2003-10-10 11:23 ` Magnus Andersson
0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Tosatti @ 2003-10-09 19:37 UTC (permalink / raw)
To: Magnus Andersson; +Cc: linux-kernel
On Wed, 8 Oct 2003, Magnus Andersson wrote:
> Hello!
>
> If I open one file a lot of times using the flag O_DIRECT,
> memory seems to be be lost and never given back to the system.
> This is happening on some kernels, see below for which ones I tried.
>
> Attached program will produce this behavior, also attached
> is the output from vmstat while running the program.
Magnus,
That memory will be freed as soon as there's memory pressure so its not a
memory leak.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 2.4.22 O_DIRECT memory leak?!?
2003-10-09 19:37 ` Marcelo Tosatti
@ 2003-10-10 11:23 ` Magnus Andersson
0 siblings, 0 replies; 3+ messages in thread
From: Magnus Andersson @ 2003-10-10 11:23 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]
On Thu, Oct 09, 2003 at 04:37:52PM -0300, Marcelo Tosatti wrote:
>
>
> On Wed, 8 Oct 2003, Magnus Andersson wrote:
>
> > Hello!
> >
> > If I open one file a lot of times using the flag O_DIRECT,
> > memory seems to be be lost and never given back to the system.
> > This is happening on some kernels, see below for which ones I tried.
> >
> > Attached program will produce this behavior, also attached
> > is the output from vmstat while running the program.
>
> Magnus,
>
> That memory will be freed as soon as there's memory pressure so its not a
> memory leak.
Ok. It's not a leak. But it looks like the memory never goes back to the system.
The kernel has killed some processes of mine, thats why I suspect this.
Attached are a program, malloc_mem.
Before running open_odirect, malloc_mem succeeds in allocating 450 000 000 bytes.
After running open_odirect, malloc_mem fails.
It is working on the 2.4.22-aa1 kernel, but not on 2.4.22
The test is run with this amount of memory, and no swap.
Memory: 515752k/524204k available (1593k kernel code, 8064k reserved, 334k data, 264k init, 0k highmem)
/Magnus
[-- Attachment #2: run.log --]
[-- Type: text/plain, Size: 112 bytes --]
foo:~> ./malloc_mem
All ok!
foo:~> ./open_odirect
foo:~> ./malloc_mem
Could not malloc 450000000 bytes
foo:~>
[-- Attachment #3: malloc_mem.c --]
[-- Type: text/plain, Size: 266 bytes --]
#include <stdio.h>
#define MEM_SIZE 450000000
int main()
{
int i;
char *mem;
mem = (char *)malloc(MEM_SIZE);
if(mem == NULL) {
printf("Could not malloc %d bytes\n", MEM_SIZE);
exit(1);
}
memset(mem, 1, MEM_SIZE);
printf("All ok!\n");
}
[-- Attachment #4: vmstat.output --]
[-- Type: text/plain, Size: 2388 bytes --]
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 0 496804 940 7936 0 0 0 0 101 2 0 0 100 0
0 0 0 496800 940 7940 0 0 0 0 101 6 0 0 100 0
0 0 0 496800 940 7940 0 0 0 0 101 4 0 0 100 0
0 0 0 496800 940 7940 0 0 0 0 101 2 0 0 100 0
0 0 0 496800 940 7940 0 0 0 0 101 2 0 0 100 0
1 0 0 438912 940 7940 0 0 0 0 104 14 71 28 1 0
1 0 0 379896 940 7940 0 0 0 0 101 4 76 24 0 0
1 0 0 320880 940 7940 0 0 0 0 101 4 78 22 0 0
1 0 0 261868 940 7940 0 0 0 0 101 2 74 26 0 0
1 0 0 202848 940 7940 0 0 0 0 101 2 77 23 0 0
1 0 0 143836 940 7940 0 0 0 0 101 2 73 27 0 0
1 0 0 84856 940 7940 0 0 0 0 101 8 76 24 0 0
0 0 0 496716 940 7940 0 0 0 0 105 13 35 17 49 0
0 0 0 496716 940 7940 0 0 0 0 101 2 0 0 100 0
0 0 0 496716 940 7940 0 0 0 0 101 2 0 0 100 0
0 0 0 496716 940 7940 0 0 0 0 107 16 0 0 100 0
0 0 0 496716 940 7940 0 0 0 0 104 11 0 0 100 0
1 0 0 461916 940 7940 0 0 0 128 137 27 0 17 83 0
0 0 0 385028 940 7940 0 0 0 0 103 7 0 50 50 0
0 0 0 385028 940 7940 0 0 0 0 101 2 0 0 100 0
0 0 0 385028 940 7940 0 0 0 0 101 4 0 0 100 0
0 0 0 385028 940 7940 0 0 0 0 107 20 0 0 100 0
0 0 0 385028 940 7940 0 0 0 76 126 22 0 0 100 0
0 0 0 385028 940 7940 0 0 0 0 101 2 0 0 100 0
0 0 0 385028 940 7940 0 0 0 0 101 2 0 0 100 0
0 0 0 385024 940 7944 0 0 0 0 101 2 0 0 100 0
0 0 0 385024 940 7944 0 0 0 0 101 4 0 0 100 0
0 0 0 385024 940 7944 0 0 0 0 101 4 0 0 100 0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-10-10 11:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-08 16:09 2.4.22 O_DIRECT memory leak?!? Magnus Andersson
2003-10-09 19:37 ` Marcelo Tosatti
2003-10-10 11:23 ` Magnus Andersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®