I'm writing image processing program on BCB. But, for huge amount of memory allocation BCB doesn't works properly.
I want to allocate nearly 2 GB (total) dynamic arrays. For 1,5 GB there is no problem. But when this size incresing it gives bad allocation error.
In that computer there is 2 GB physical memory and I use WinXP (and I add /3GB to boot.ini).
For testing I wrote an Visual C++ code in another PC which has 1 GB phyisical RAM. In the below code Visual C++ can allocate 1600 MB memory. But this code can allocate only 794 MB on BCB. What can I do? Please help...
Expand|Select|Wrap|Line Numbers
- DWORD dwSize = 1024*1024*1600;
- LPVOID pvBase = VirtualAlloc(NULL, dwSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
- if (NULL != pvBase)
- {
- //For test only...
- LPBYTE MyPointer = (LPBYTE)pvBase;
- MyPointer[0]=15;
- MyPointer[1]=20;
- }
- else
- {
- // GetLastError
- }
- VirtualFree(pvBase, 0, MEM_DECOMMIT);
- VirtualFree(pvBase, 0, MEM_RELEASE);
- pvBase = NULL;