Hi, i have a problem with windows system cache. Sample code:
int main(int argc, char* argv[])
{
HANDLE file_ = INVALID_HANDLE_VALUE;
file_ = CreateFile(
"test_file.txt",
GENERIC_WRITE,
FILE_SHARE_READ,
0,
OPEN_ALWAYS,
FILE_FLAG_SEQUENTIAL_SCAN,
NULL
);
if (file_ == INVALID_HANDLE_VALUE || file_ == NULL)
{
std::cout << "CreateFile error " << GetLastError() << std::endl;
return GetLastError();
}
int counter = 0;
DWORD io_bytes = 0;
while(true)
{
char buffer[0x1000];
int len = _snprintf_s(buffer, 0x1000, 0xffff, "test message %d\r\n", counter);
counter++;
if ( !WriteFile(file_, buffer, len, &io_bytes, NULL) )
{
std::cout << "WriteFile error " << GetLastError() << std::endl;
return GetLastError();
}
if (counter > 10000000)
{
system("pause");
return 0;
}
}
}
if you run this code and look at system cache size, all will be ok. But if you open this file(test_file.txt) for reading in some viewer(for exemple with lister plugin for total commander) while this program is running, you will see, that system cache size is growing, even if you already close your viewer program. This looks like memory leak. Is this behavior normal?