Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Huge amount of memory allocation with BCB

Status
Not open for further replies.

murataykut

Programmer
Jul 9, 2004
1
TR
Hi,
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...

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;


 
Hi,

I'm having a similar issue. Did you manage to solve this problem?

thanks
 
There are alot of things that affect how memory is allocated. I would be interest in seeing what happens when the VC++ program is run on the same machine as the BCB program.

One of the tricks I've seen to get around this is to write to a buffer on the hard drive. I don't know if this would work in your cases, though.


James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top