Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12

    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
  2. #2
  3. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    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.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12
    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.
  6. #4
  7. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    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.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12
    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 :D
  10. #6
  11. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    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)
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12
    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
  14. #8
  15. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    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
  16. #9
  17. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12
    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
  18. #10
  19. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    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.

    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.
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    11
    Rep 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!
  22. #12
  23. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12
    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
  24. #13
  25. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
    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.
  26. #14
  27. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,594
    Rep Power
    4207
    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.
  28. #15
  29. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12
    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
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo