Jack
2009-12-18 10:10:19 UTC
Hi guys,
When I run my application with the following
coding, it suffers from memory leaks of 4 bytes of
about 10-20 chunks...
[code]
__int64 FileSize64( const char * szFileName )
{
struct __stat64 fileStat;
int err = _stat64( szFileName, &fileStat );
if (0 != err) return 0;
return fileStat.st_size;
}
HRESULT LoadMesh(const char *szfilename)
{
PBYTE pMappedFileBase = NULL;
FILE *fp = fopen (szPath, "rb");
if (fp == NULL)
OutputDebugStringA("File open error\n");
__int64 si = FileSize64(szPath);
int actlen = si-4;
// I have tried using the std::vector<BYTE> v(len) technique,
// but I've got the same results.
pMappedFileBase = new BYTE[actlen];
memset (pMappedFileBase, 0, actlen);
..
if (pMappedFileBase)
{
delete[] pMappedFileBase;
pMappedFileBase = NULL;
}
[/code]
It is similar to the eariler case I posted in here,
as it suffered from memory leaks as well.
00 00 00 00 00 00 00....
fd fd fd fd
I've checked many places including the opened file itself and the stack..
When I don't use si-4 for actlen, but si, the fd bytes
were shifted down for another 4 bytes
like this,
00 00..
00 00 00 00 fd fd fd fd
I am totally exhausted because this problem has baffled me for 2 days for
many hours...so please help!
Thanks and again
Jack
When I run my application with the following
coding, it suffers from memory leaks of 4 bytes of
about 10-20 chunks...
[code]
__int64 FileSize64( const char * szFileName )
{
struct __stat64 fileStat;
int err = _stat64( szFileName, &fileStat );
if (0 != err) return 0;
return fileStat.st_size;
}
HRESULT LoadMesh(const char *szfilename)
{
PBYTE pMappedFileBase = NULL;
FILE *fp = fopen (szPath, "rb");
if (fp == NULL)
OutputDebugStringA("File open error\n");
__int64 si = FileSize64(szPath);
int actlen = si-4;
// I have tried using the std::vector<BYTE> v(len) technique,
// but I've got the same results.
pMappedFileBase = new BYTE[actlen];
memset (pMappedFileBase, 0, actlen);
..
if (pMappedFileBase)
{
delete[] pMappedFileBase;
pMappedFileBase = NULL;
}
[/code]
It is similar to the eariler case I posted in here,
as it suffered from memory leaks as well.
00 00 00 00 00 00 00....
fd fd fd fd
I've checked many places including the opened file itself and the stack..
When I don't use si-4 for actlen, but si, the fd bytes
were shifted down for another 4 bytes
like this,
00 00..
00 00 00 00 fd fd fd fd
I am totally exhausted because this problem has baffled me for 2 days for
many hours...so please help!
Thanks and again
Jack