C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 4th, 2003, 04:15 AM
marek_haj's Avatar
marek_haj marek_haj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: currently Lisbone, Portugal
Posts: 154 marek_haj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 28 m
Reputation Power: 6
Lightbulb Maximum matrix size

Hello
while writing one of my funny programs, I tried teh declaration X[25][25][25][1024] and then the linker made a really nice thing - just hang up. Every time I try to do that it keeps on doing the same stuff. I assume that I exceed the size limit for an allocated matrix. Can anyone tell me what is the maximum size for a matrix under Builder c++??
Thanks for all posts
Greets
MArek

Reply With Quote
  #2  
Old April 4th, 2003, 05:59 AM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 6
I believe it is 256 megs, but it depends on your compiler.

Note that it is only 256 Kb from within a function (and main() is a function), since you are allocating it on the stack (remember, that you can call main() from inside your program, and it has to reallocate more memory for this call). The stack size may vary with your compiler and settings, though.

Reply With Quote
  #3  
Old April 4th, 2003, 06:08 AM
marek_haj's Avatar
marek_haj marek_haj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: currently Lisbone, Portugal
Posts: 154 marek_haj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 28 m
Reputation Power: 6
in that case, how to check what is the maximum allowed matrix size?? I need that badly because I make recursive calculations and I have to store all the intermediate results in the matrix since they are summed up.

Reply With Quote
  #4  
Old April 4th, 2003, 07:11 AM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 6
I have no idea. I believe it is 256 MB. Just make sure you do not declare it inside of main() if you want the maximum size.

Reply With Quote
  #5  
Old April 4th, 2003, 07:31 AM
marek_haj's Avatar
marek_haj marek_haj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: currently Lisbone, Portugal
Posts: 154 marek_haj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 28 m
Reputation Power: 6
thanks a lot
at least I know what size it can be, nevertheless 25x25x25x1024x2 is much less than 256Megs (a little more than 30) and still the linker does not seem to like that. Well, I will have to write an email to the guys from Borland, maybe they will know how to fix that.
Thanks a lot for the post.
Best greets
MArek

Reply With Quote
  #6  
Old April 4th, 2003, 09:00 AM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 6
You shouldn't email the guys at Borland, because they don't need to 'fix' anything, as nothing is broken. You should let us know where you are defining this array, because it matters, as I have stated above. Most likely, you are defining it within the function main() in which you are far exceeding the limit (256 Kb on my compiler with the current settings = 1/4th of a MB)

Reply With Quote
  #7  
Old April 4th, 2003, 09:53 AM
marek_haj's Avatar
marek_haj marek_haj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: currently Lisbone, Portugal
Posts: 154 marek_haj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 28 m
Reputation Power: 6
part of the program goes like this: (copied it from the .cpp file)

//---------------------------------------------------------------------------

#include <vcl.h>
#include <math.h>
#include <stdio.h>

#pragma hdrstop

#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CGAUGES"
#pragma resource "*.dfm"
TForm7 *Form7;

extern char sciezka[512];
extern char nazwa[512];

const F = 10;
const N = 1024;
int iWavelengthNumber, iNodeNumber, iOutgoingLinksNumber, iTopologyDegree, iLinksNumber, iExitLinksNumber;
int iWavelengthNumberMin, iWavelengthNumberMax, iWavelengthNumberStep, iNodeNumberMin, iNodeNumberMax, iNodeNumberStep;
int iLoadMin, iLoadMax, iLoadStep, iConversionDensityMin,iConversionDensityMax,iConversionDensityStep;
float fConversionDensity, fRoe, fRoc, fRo,fExpectedPathLength,fAverageNumberofNodes,fAverageFractionofNodes;
Extended ftPI[F+1][F+1][F+1],ftQ[F+1],ftR[F+1][F+1][F+1][F+1],ftU[F+1][F+1][F+1],ftS[F+1][F+1],ftT[F+1][F+1],ftTemp[F+1][F+1];
Extended ftPb[F+1][N],[B]ftV[F+1][F+1][F+1][N],ftW[F+1][F+1][N],fNumerator,fDenominator;
bool bModel;
enum Topology {ringu, ringb, mesh, meshodd, mesheven, ringmesh, hypercube, random_t} eTopology;

float fVar1,fVar2,fVar3;
int iVar1,iVar2,iVar3,iVar4,iVar5,iVar6,iVar7,iVarA,iLimits;
long int liVar1;
long double ldResult;

// function definitions

float Probability(void);
float PL (int);
float PL (int);
float RandomPL(int, int);
float minimum(float,float);
float maximum(float,float);
long int Factorial(int);
long double Power(long double, long double);
void BasicParametersEstimation(void);
void LoadCalculationRoutine(void);
void InitializeProbabilities(void);
void CalculatePb(int);
void ZeroAllTables(void);

FILE *plik2;

//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
: TForm(Owner)
{
}

when I turn the F constant to 25 the way I want it to be, the linker hangs up the whole Builder. I am using Builder c++ 5. The problem is with the declaration in the line
Extended ftPb[F+1][N],[B]ftV[F+1][F+1][F+1][N],ftW[F+1][F+1][N],fNumerator,fDenominator;
the ftV[F+1][F+1][F+1][N], function seems to exceed the limits.
Thanks for reply
Greets
MArek

Reply With Quote
  #8  
Old April 4th, 2003, 01:49 PM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 6
Make a simple program and test different array sizes until you see what the maximum is. It should be some even computer number, unless something is really screwed up.

In any case, if your windows machine has much more memory than what your program needs, and your compiler cannot handle it, you need to either:
1. get a better compiler
2. change the settings of your compiler
3. use dynamic memory allocation

Reply With Quote
  #9  
Old April 5th, 2003, 02:23 AM
marek_haj's Avatar
marek_haj marek_haj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: currently Lisbone, Portugal
Posts: 154 marek_haj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 28 m
Reputation Power: 6
Hello again,
I have toyed with compiler settings a lot by now and it does not seem to have a particulat effect on this error. Sometimes instead of hanging up it just issues the error saying "Please contact technical support" or something like that. God knows why
Abotu getting a better compiler, what does it mean a better one? A newer version? Like Builder c++ 6.0? I have downloaded it yesterday, might as well try it. I will tell You all if it helps or not.
And dynamic memeory allocation did not help either. The same story, the same crash
Well, thanks a lot. My professor agreed to limits the parameters down so that it does not cause any memory breach. Anyhow, I was just curious about something like this.
Best greets
MArek

Reply With Quote
  #10  
Old April 5th, 2003, 10:06 AM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 6
Quote:
Originally posted by marek_haj
Abotu getting a better compiler, what does it mean a better one? A newer version? Like Builder c++ 6.0?
I mean that my compiler can handle arrays that large, so your compiler should be able to, as well - since if there is any limit to memory, it is because of the amount of RAM you have, or your CPU capabilities. Perhaps you are compiling it in one of the older execution modes, which does not allow a large amount of memory. My knowledge in this area is quite limited, I would have to look it up to see what the limitations are on specific models.

Quote:
Originally posted by marek_haj
And dynamic memeory allocation did not help either. The same story, the same crash
Try dynamically allocating it in pieces at a time.

Reply With Quote
  #11  
Old April 5th, 2003, 01:02 PM
Doctor - A Doctor - A is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 11 Doctor - A User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
win32 support 4GB size for every section (code, stack, data).
But it is virtula memory with swapping to disk.
So max size depends from free disk space too!

Reply With Quote
  #12  
Old April 7th, 2003, 03:10 AM
marek_haj's Avatar
marek_haj marek_haj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: currently Lisbone, Portugal
Posts: 154 marek_haj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 28 m
Reputation Power: 6
Hello, sorry for a late post but I have been away at the weekend.
About the hardware, at the moment I am working on PIV 2.8GHz with 1,5GB of DDR and 380GB HDD drive, most of it still free. I think that the hardware limitations are not the problem therefore.
With this execution mode - what is the story on that? I have browsed through all the linker and compiler options and all of them are set to be comiplant with Pentium extended mode. Probably I should make printsceerns of the option settings and attach them, perhaps that might help in solving that puzzle.
Thanks for posts
Best greets
MArek

Reply With Quote
  #13  
Old April 10th, 2003, 03:01 PM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 6
In another forum, I seen someone having a problem with running out of heap space. The error returned was:

fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit

You may wish to look into these settings to see if you can solve your problem.

Reply With Quote
  #14  
Old April 11th, 2003, 12:29 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,442 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 h 22 m 8 sec
Reputation Power: 797
I tried cutting and pasting your code into C++ Builder 6.0 and it compiled fine. Just to be certain, have you tried fiddling with the settings under Project-->Options-->Linker? BTW local variables are allocated on the stack and global variables, static variables and malloced memory are allocated from the heap, so depending on what you're using, you may need to adjust the settings accordingly.

[edit]Forgot to mention that the cut-and-paste compiled fine with default project settings on Borland C++ Builder 6.0.[/edit]

Last edited by Scorpions4ever : April 11th, 2003 at 12:38 AM.

Reply With Quote
  #15  
Old April 11th, 2003, 03:07 AM
marek_haj's Avatar
marek_haj marek_haj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: currently Lisbone, Portugal
Posts: 154 marek_haj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 28 m
Reputation Power: 6
thanks for posts
->Jason Doucette: this is not the kind of error I receive. I get the message: Fatal linker error. Unable to open the project file (Projest file alreadu in IDE?), when I press F1 for surther help, I get the message to cobntact the Borladg Tech Support. Cute, isn't it?
->Scorpions4ever: try changing const F to 25 the way I need it, when F is set to 10 all works fine with my linker as well, but when I turn it to 25 well strange things happen. If it works fine then I will send You a screet shot of thy Linker and Compiler settings, maybe You will be able to figure that out.
Thanks for all posts and see You soon I hope
Best wishes
MArek

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages