lkml.org 
[lkml]   [2003]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject2.4.22 O_DIRECT memory leak?!?
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
#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);
}
}
}
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
\
 
 \ /
  Last update: 2005-03-22 13:49    [W:0.073 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site