Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Can Dynamic 2D arrays solve stack overflow problem?

Can Dynamic 2D arrays solve stack overflow problem?

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KaKa
    wrote on last edited by
    #1

    Hi, I wrote a piece of code which initially uses a 128 by 47 2D array. It works fine. But when I changed it to 1600 rows by 47 columns, the program starts to crash. The error message said that a stack overflow has occured. I would like to know if dynamic 2D arrays solve this problem? There are also some 1D arrays with the size of 1600. Do they have to be converted to dynamic arrays too?

    W M D 3 Replies Last reply
    0
    • K KaKa

      Hi, I wrote a piece of code which initially uses a 128 by 47 2D array. It works fine. But when I changed it to 1600 rows by 47 columns, the program starts to crash. The error message said that a stack overflow has occured. I would like to know if dynamic 2D arrays solve this problem? There are also some 1D arrays with the size of 1600. Do they have to be converted to dynamic arrays too?

      W Offline
      W Offline
      Waldermort
      wrote on last edited by
      #2

      Wouldn't it be easier to use a vector?

      1 Reply Last reply
      0
      • K KaKa

        Hi, I wrote a piece of code which initially uses a 128 by 47 2D array. It works fine. But when I changed it to 1600 rows by 47 columns, the program starts to crash. The error message said that a stack overflow has occured. I would like to know if dynamic 2D arrays solve this problem? There are also some 1D arrays with the size of 1600. Do they have to be converted to dynamic arrays too?

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        What is the size of the data? an array of what ? dynamic arrays might or might not fix your problem if it's a size issue.


        Maximilien Lincourt Your Head A Splode - Strong Bad

        1 Reply Last reply
        0
        • K KaKa

          Hi, I wrote a piece of code which initially uses a 128 by 47 2D array. It works fine. But when I changed it to 1600 rows by 47 columns, the program starts to crash. The error message said that a stack overflow has occured. I would like to know if dynamic 2D arrays solve this problem? There are also some 1D arrays with the size of 1600. Do they have to be converted to dynamic arrays too?

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          75,200 ints would require 300,800 bytes of stack. If that were a double, it would require 601,600 bytes of stack, over half of the default value. Pass that around to only a few functions and the stack could be exhausted very easily.


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups