K
Kumar Abhinav
Hello All,
I am trying to memory mappin technique to parse zone file. The program is
running fine for small file of size around 350MB but the same program failes
when the file size becomes 2.5GB
Here is a simple program which works fine for small files but fails for
large files:
<code>#include <windows.h>
#include<stdio.h>
int main(void)
{
char * p1stData;
HANDLE hMap1stFile;
HANDLE h1stFile;
LPVOID lp1stMapAddress;
h1stFile = CreateFile("biz.zone", GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (h1stFile == INVALID_HANDLE_VALUE)
{
printf("h1stFile is NULL\n");
printf("Target file is %s\n", "biz.zone");
return 4;
}
hMap1stFile = CreateFileMapping( h1stFile, // current file handle
NULL, // default security
PAGE_READWRITE, // read/write permission
0, // size of mapping object, high
0,//dwFileMapSize, // size of mapping object, low
NULL); // name of mapping object
if (hMap1stFile == NULL)
{
printf("hMap1stFile is NULL: last error: %d\n", GetLastError() );
return (2);
}
lp1stMapAddress = MapViewOfFile(hMap1stFile, // handle to mapping
object
FILE_MAP_ALL_ACCESS, // read/write
permission
0, // high-order 32 bits of file offset
0,//dwFileMapStart, // low-order 32 bits
of file offset
0); // number of bytes to map
if (lp1stMapAddress == NULL)
{
printf("lp1stMapAddress is NULL: last error: %d\n", GetLastError());
return 3;
}
p1stData = (char *) lp1stMapAddress;//+ iViewDelta;
for(int i=0;i<1000;i++)
{
printf("%c",*p1stData);
}
return 0;
}</code>
The error that comes is:
hMap1stFile is NULL: last error: 1006
Is there any upper limit on the file size which can be memory mapped.
I am trying to memory mappin technique to parse zone file. The program is
running fine for small file of size around 350MB but the same program failes
when the file size becomes 2.5GB
Here is a simple program which works fine for small files but fails for
large files:
<code>#include <windows.h>
#include<stdio.h>
int main(void)
{
char * p1stData;
HANDLE hMap1stFile;
HANDLE h1stFile;
LPVOID lp1stMapAddress;
h1stFile = CreateFile("biz.zone", GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (h1stFile == INVALID_HANDLE_VALUE)
{
printf("h1stFile is NULL\n");
printf("Target file is %s\n", "biz.zone");
return 4;
}
hMap1stFile = CreateFileMapping( h1stFile, // current file handle
NULL, // default security
PAGE_READWRITE, // read/write permission
0, // size of mapping object, high
0,//dwFileMapSize, // size of mapping object, low
NULL); // name of mapping object
if (hMap1stFile == NULL)
{
printf("hMap1stFile is NULL: last error: %d\n", GetLastError() );
return (2);
}
lp1stMapAddress = MapViewOfFile(hMap1stFile, // handle to mapping
object
FILE_MAP_ALL_ACCESS, // read/write
permission
0, // high-order 32 bits of file offset
0,//dwFileMapStart, // low-order 32 bits
of file offset
0); // number of bytes to map
if (lp1stMapAddress == NULL)
{
printf("lp1stMapAddress is NULL: last error: %d\n", GetLastError());
return 3;
}
p1stData = (char *) lp1stMapAddress;//+ iViewDelta;
for(int i=0;i<1000;i++)
{
printf("%c",*p1stData);
}
return 0;
}</code>
The error that comes is:
hMap1stFile is NULL: last error: 1006
Is there any upper limit on the file size which can be memory mapped.