codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  memory allocation with borland 5.5 compiler  abemagro at 12:16 on Thursday, September 29, 2005
 

Hello,
I am running Borland 5.5 Compiler.
I should work with big arrays.
My program compile and works fine with small arrays but when i increase the size (more than 15000 float elements)it compiles but it deosnt work.
I think the problem is a lack of memory.
So i tried to allocate memory with the command ilink32 -H:
but it did not work,.
Does anybody know how to increase the size of the memory allocated with borland 5.5 compiler for windows (dos).


thank you

Alberto

  Re: memory allocation with borland 5.5 compiler  geTTysburg at 22:10 on Friday, October 14, 2005
 

Unless you are compiling project as DPMI-32(DOS Protected Mode) or Win32 Console program, memory allocation is limited to 64KB chunks. This means that any one object in your program can't exceed 64KBytes. DPMI32 and WIN32 concole programs have 32-bit addressing.

The size of a float is 4-bytes. An arrray of float with 15,000 elements is 60,000KB. You can have of approx. 16,380 elements with no problems.


DPMI-32 projects are only available with Borland C++ v4.52; and then only if you've installed the "PowerPack Add-on"

I compile using Boland C++ 5.02 IDE for quick & dirty programs, and C++ Builder v6 for larger projects. I believe the 5.02 IDE used v5.2 of Boland's C/C++ compiler. Both have an option for creating WIN32 console projects. Not familiar with command-line compiler, but I have to think you can compile program as WIN32 Console. Probably have to use BCC32.EXE instead of BCC.EXE.




  Re: memory allocation with borland 5.5 compiler  geTTysburg at 22:10 on Friday, October 14, 2005
 

Unless you are compiling project as DPMI-32(DOS Protected Mode) or Win32 Console program, memory allocation is limited to 64KB chunks. This means that any one object in your program can't exceed 64KBytes. DPMI32 and WIN32 concole programs have 32-bit addressing.

The size of a float is 4-bytes. An arrray of float with 15,000 elements is 60,000KB. You can have of approx. 16,380 elements with no problems.


DPMI-32 projects are only available with Borland C++ v4.52; and then only if you've installed the "PowerPack Add-on"

I compile using Boland C++ 5.02 IDE for quick & dirty programs, and C++ Builder v6 for larger projects. I believe the 5.02 IDE used v5.2 of Boland's C/C++ compiler. Both have an option for creating WIN32 console projects. Not familiar with command-line compiler, but I have to think you can compile program as WIN32 Console. Probably have to use BCC32.EXE instead of BCC.EXE.




  Re: memory allocation with borland 5.5 compiler  geTTysburg at 22:11 on Friday, October 14, 2005
 

Unless you are compiling project as DPMI-32(DOS Protected Mode) or Win32 Console program, memory allocation is limited to 64KB chunks. This means that any one object in your program can't exceed 64KBytes. DPMI32 and WIN32 concole programs have 32-bit addressing.

The size of a float is 4-bytes. An arrray of float with 15,000 elements is 60,000KB. You can have of approx. 16,380 elements with no problems.


DPMI-32 projects are only available with Borland C++ v4.52; and then only if you've installed the "PowerPack Add-on"

I compile using Boland C++ 5.02 IDE for quick & dirty programs, and C++ Builder v6 for larger projects. I believe the 5.02 IDE used v5.2 of Boland's C/C++ compiler. Both have an option for creating WIN32 console projects. Not familiar with command-line compiler, but I have to think you can compile program as WIN32 Console. Probably have to use BCC32.EXE instead of BCC.EXE.




  Re: memory allocation with borland 5.5 compiler  geTTysburg at 22:44 on Friday, October 14, 2005
 

Don't know what's up with the three identical replies. Anyway, if you want to compile a WIN32 console program using command-line compiler, just include the "-WC" option which indicates "Windows console" compile.

I compiled the source code below with the simple command line:

BCC32.EXE test.cpp -WC <Enter>

I tested the resulting executable against a 13MByte input file. Since the input file was 13MBytes in size, the character array I created was also 13Mbytes in size. I performed a file compare against input and output files and they were identical so the program is working correctly.

Hope this helps.

//*************************************
//This program does the following:
// - opens a file for reading
// - creates a character array the size of the file.
// - reads file contents into character array
// - writes character array to output file.
//*************************************
#include <stdio.h>
#include <stdlib.h>
#include <io.h>

main(int argc, char **argv)
{
//*************************************
// argv[1] - input file
// argv[2] - output file
//*************************************


char *buffer;
int amt_read;
FILE *infile;

infile=fopen(argv[1], "rb");
if(!infile){
printf("Unable to open [%s]\n\n", argv[1]);
return 0;
}

amt_read = filelength(fileno(infile));
buffer = new char[amt_read+1];
fread(buffer, sizeof(char), amt_read, infile);
buffer[amt_read]='\0';
fclose(infile);

infile=fopen(argv[2], "wb");
if(!infile){
printf("Unable to open [%s]\n\n", argv[2]);
return 0;
}

fwrite(buffer, sizeof(char), amt_read, infile);
fclose(infile);


return 0;
}
//*************************************
//*************************************











CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem
•  Re: import contacts of msn/yahoo


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007