473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Allocating Huge Amount of Memory in BCB

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...

Expand|Select|Wrap|Line Numbers
  1.   DWORD dwSize = 1024*1024*1600;
  2.   LPVOID pvBase = VirtualAlloc(NULL, dwSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
  3.   if (NULL != pvBase)
  4.   {
  5.     //For test only...
  6.     LPBYTE MyPointer = (LPBYTE)pvBase;
  7.     MyPointer[0]=15;
  8.     MyPointer[1]=20;
  9.   }
  10.   else
  11.   {
  12. //    GetLastError
  13.   }
  14.   VirtualFree(pvBase, 0, MEM_DECOMMIT);
  15.   VirtualFree(pvBase, 0, MEM_RELEASE);
  16.  
  17.   pvBase = NULL;
  18.  
Nov 8 '07 #1
1 2211
Banfa
9,065 Expert Mod 8TB
I assume BCB is Borland C++ Builder?

Try allocating your memory in smaller chunks, if necessary create an ADT (abstract data type) that allows you to access the chunks as if they where a single array.

Alternitively 2GB is rather a lot of data to hold in memory, put it in a file, make the file MemoryMapped and again create an ADT to access it as though it where an array.
Nov 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Henrietta Denoue | last post by:
Hi I am new to C++ and suffering from dynamic allocation. I have a function that returns an integer pointer and want to assign this to another pointer: class cssReader { public:
15
by: fix | last post by:
Hi all, I am writing a program using some structs, it is not running and I believe it is because there's some memory leak - the debugger tells me that the code causes the problem is in the malloc...
5
by: Johnathan Doe | last post by:
Why is is necessary to write a function that allocates memory for, or changes, a pointer to a char array using char** instead of char*? E.g. void modify_string( char** string ) { if( string...
7
by: Vasil Buraliev | last post by:
Hallo. I started a solution in VS.NET with template for C# windwos application. The solution has several projects: -Artifacts -BusinessRules -Client -ErrorLog -Standardization .... ... ..
3
by: Tod Birdsall | last post by:
Hi All, The organization I am working for has created a new corporate website that used Microsoft's Pet Shop website as their coding model, and dynamically served up content, but cached each...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
19
by: allanallansson | last post by:
Hi i would like some guidelines for a experiment of mine. I want to experiment with the swap and ctrl-z in linux. And for this i want to create a c program that allocates almost all the free memory...
16
by: pereges | last post by:
ok so i have written a program in C where I am dealing with huge data(millions and lots of iterations involved) and for some reason the screen tends to freeze and I get no output every time I...
13
by: charlie | last post by:
I came up with this idiom for cases where a function needs a variable amount of memory for it's temporary storage so as to avoid constantly mallocing. It makes me feel a little uncomfortable to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.