Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt arrays with more than [500000] indexes
Forum Updated to NodeBB v4.3 + New Features

Qt arrays with more than [500000] indexes

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 5 Posters 696 Views 5 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.
  • N Offline
    N Offline
    nifroidl
    wrote on last edited by
    #1

    Hello,

    right now im creating a software fro my university and we want to analise two .csv files which have both about 300.000 lines! So i wanna put each of them into a QStringList array like this:

    QStringList arr1[300000], arr2[300000];

    And exactly there is where my problem starts. I tested it and the prolem is, when I creat arraays which indexes are summed up over ~500.000 then the pogramm will not start! Following program works:

    QStringList arr1[250000], arr2[250000];

    Thats actually my main problem, can please somebody help me?

    Thaks a lot!

    N 1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #7

      Google is very helpful:
      https://www.geeksforgeeks.org/stack-vs-heap-memory-allocation/

      C++ is a perfectly valid school of magic.

      N 1 Reply Last reply
      4
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #2

        First determine size of QString() when empty. Then multiply this by 500000. Determine if this is bigger than your stack size (most likely). You are most likely experiencing a stack overflow. You can only allocate so much space on the stack before you run out of room. If you want big sets of data you want to allocate on the heap.

        C++ is a perfectly valid school of magic.

        N 1 Reply Last reply
        4
        • artwawA Offline
          artwawA Offline
          artwaw
          wrote on last edited by
          #3

          Hi.
          have you considered using QTextStream? CSV files are text, unless for some reason you need to keep those files in memory there is no need to load them all at once.

          For more information please re-read.

          Kind Regards,
          Artur

          N 1 Reply Last reply
          0
          • fcarneyF fcarney

            First determine size of QString() when empty. Then multiply this by 500000. Determine if this is bigger than your stack size (most likely). You are most likely experiencing a stack overflow. You can only allocate so much space on the stack before you run out of room. If you want big sets of data you want to allocate on the heap.

            N Offline
            N Offline
            nifroidl
            wrote on last edited by
            #4

            @fcarney

            Actually i dont really understand what I have to do when I want to implent ur idea... Could u explai it a bit more precisly for me?

            1 Reply Last reply
            0
            • artwawA artwaw

              Hi.
              have you considered using QTextStream? CSV files are text, unless for some reason you need to keep those files in memory there is no need to load them all at once.

              N Offline
              N Offline
              nifroidl
              wrote on last edited by
              #5

              @artwaw
              Thanks for ur answer but for my project it is important to safe the files, thatswhy i prefere Stringlist, but actually im more interested to solve the problem i told because i dont understand why i dont can create an aray of e.g. 1.000.000...

              artwawA 1 Reply Last reply
              0
              • N nifroidl

                @artwaw
                Thanks for ur answer but for my project it is important to safe the files, thatswhy i prefere Stringlist, but actually im more interested to solve the problem i told because i dont understand why i dont can create an aray of e.g. 1.000.000...

                artwawA Offline
                artwawA Offline
                artwaw
                wrote on last edited by
                #6

                @nifroidl But you can read/write transparently using streams. They just take care of I/O operations for you, once properly associated with the files, and it is hard to run out of memory too. Of course, using them is a bit more complicated than simple string list. Perhaps if you could share the algorithm/workflow we could be more helpful?

                For more information please re-read.

                Kind Regards,
                Artur

                1 Reply Last reply
                0
                • fcarneyF Offline
                  fcarneyF Offline
                  fcarney
                  wrote on last edited by
                  #7

                  Google is very helpful:
                  https://www.geeksforgeeks.org/stack-vs-heap-memory-allocation/

                  C++ is a perfectly valid school of magic.

                  N 1 Reply Last reply
                  4
                  • fcarneyF fcarney

                    Google is very helpful:
                    https://www.geeksforgeeks.org/stack-vs-heap-memory-allocation/

                    N Offline
                    N Offline
                    nifroidl
                    wrote on last edited by
                    #8

                    @fcarney

                    Thanksa a lot!

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #9

                      Hi,

                      @nifroidl said in Qt arrays with more than [500000] indexes:

                      QStringList arr1[250000], arr2[250000];

                      Do you realize that you are declaring two big arrays of QStringList ?

                      Using two QVector of QStringList if you want to store there the content of your files will get you further.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      4
                      • N nifroidl

                        Hello,

                        right now im creating a software fro my university and we want to analise two .csv files which have both about 300.000 lines! So i wanna put each of them into a QStringList array like this:

                        QStringList arr1[300000], arr2[300000];

                        And exactly there is where my problem starts. I tested it and the prolem is, when I creat arraays which indexes are summed up over ~500.000 then the pogramm will not start! Following program works:

                        QStringList arr1[250000], arr2[250000];

                        Thats actually my main problem, can please somebody help me?

                        Thaks a lot!

                        N Offline
                        N Offline
                        Nikji
                        wrote on last edited by
                        #10

                        @nifroidl Hi i have a code, where i scanning all my system check files and sum files(lines) and paste all files to file.
                        You big files it database. Big file it type you data.Big file have format text(1 format for all lines) You ptogram it methods for find and more in you data.
                        Check themes iterator, maps,Qfile, threads,ios(tream). my scan check all my files where 1-2-3 millions lines for maximum 1 minute, and you have more methods + boost library for more methods you filesystems and check files.
                        you index its 1 format for every line. this speed
                        But if you create *arr 1gb and you put to memory this array it cache file it not way for you and not speed method

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved