Compiling in visual studio I can allocate > 4gig ram. However I cannot address all the memory specifically the memory above 4 gig
There are no issues if the allocation is less than 4gig
What am I missing?
eg // alloc large image
//#define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4)
Width = 24000;
Height = 50000;
nBitsPerPixel =32
NumberColors =0
...
BITMAPINFOHEADER* lpbmi; // pointer to a Win 3.0-style DIB
size_t Size;
Size = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)* NumberColors +WIDTHBYTES(Width*nBitsPerPixel) * Height;
try{
m_pDIB = (DWORD*)malloc (sizeof(DWORD) * (Size +3)/4); // DWORD aligned
}
…
lpbmi = (BITMAPINFOHEADER*)m_pDIB;
lpbmi->biSize = sizeof(BITMAPINFOHEADER);
lpbmi->biWidth = Width;
lpbmi->biHeight = Height;
lpbmi->biPlanes = 1;
lpbmi->biBitCount = (unsigned short)nBitsPerPixel;
m_pImage = (BYTE*)m_pDIB + *(DWORD*)m_pDIB + sizeof(RGBQUAD)*m_NumberColors;
... ok so far no run errors
''''''''''''''''''''''''''''''''''''''''
however when I address the memory
size_t p = Width *4;
BYTE* pSrc = m_pImage;
// test
for ( DWORD j = 0; j < m_Height; j++)
{
BYTE* pMem;
pMem = pSrc + size_t(j *p);
memset(pMem, 0, m_Width);
}
when j is 5261 get the error
0xC0000005: Access violation writing location
''''''''''''''''
windows 10 , visual studio 2017, 64 bit (x64)
User contributions licensed under CC BY-SA 3.0