To increase memory size for my program

I am a student currently working on large datasets. I am reading data records from a text file and storing them in arrays. I am unable to store more than 450 records. 
  
  I am working on visual c++ win32 console application. If I increase the size of array its giving me an error ' stack overflow'.

I tried even by changing stack size & heap size to MAX value : 2147483647 in the projects properties -> linker -> system . And when i changed size of array to 500 its giving me a different error 'unable to start debugging '.....'unable to start program c:/......./projectname/debug/projectname.exe'  

                   
Is there any solution for my problem. How can i increase the memory size allocated for my program. I declaring an array in a class and created a static object in main method whose reference is being shared by all other called methods.

Can anyone help me.......
      
       




Answer this question

To increase memory size for my program

  • Regent2

    How can I attach a debugger

  • cpix

    Global data is evil: don't use it.

    Make your array a member of a class and provide accessor functions to it: that way you can control who can read and write to it.

    On a 32-bit machine that is the maximum amount of memory you can every hope to allocate.

    Yes: that is the correct way to allocate an object on the stack.

  • John Cherian

  • Litoplan

    I am just sending its reference as a parameter to all recursive calls. Not by value. Will it effect the memory allocated to it  Then which is the best way u think to share the data among all methods in different classes. b'coz i want to maintain some global data to be accessed by all.

    Even heap size seems to be constant. MAX : 2147483647 bytes 

             will the dynamic allocation of object solves my problem
    myclass * obj = new myclass;

    Is it the rightway to allocate object on heap

    plz help me in solving the problem...

  • Art Johnson

    If you use new then the object is created on the heap.

    The amount of memory available on the heap is much greater than is available on the stack: in general you should not place large objects on the stack.

    I suggest that you pick up a good book on C++ and take a look at the difference between static allocation and heap allocation: the is a fundamental C++ concept and you really need to understand the difference in order to be successful at C++. Here's post I made yesterday that lists some recommended books.

    http://forums.microsoft.com/msdn/ShowPost.aspx PostID=107484

  • BlackJackDavy

    thanks for ur help.

    myclass *obj =new myclass;

    where the obj is created Is it in heap or stack

    How much memory will be available in heap and stack separately since i observed that only 1 million bytes nearly are allocated to the stack.I don't know abt heap...

    How can we make best use of it
    I mean can we allocate some objects/variables in stack and some objects/variables in heap

    how can we create objecs/variables in stack and heap

  • Geoffrey Tseng

    thanks for ur help.

  • Manik_Mahajan_3112ff

    thank you very much

  • KLSRAO

    Are you creating the array on the stack This seems problematic: why not allocate on the heap

    Also a stack overlfow exception is more generally a sign of an infinitely recusive function than it is of a true data overflow. I would attach a debugger and try to track down the cause of the exception.

  • To increase memory size for my program