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. QDataStream memory overflow [solved]
Forum Updated to NodeBB v4.3 + New Features

QDataStream memory overflow [solved]

Scheduled Pinned Locked Moved General and Desktop
14 Posts 3 Posters 3.4k 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.
  • F Offline
    F Offline
    Francknos
    wrote on last edited by
    #1

    Hi everybody,

    I have a problem in my database when I import some data.
    After checking my writting function which use datastream I found something that makes me think the problem is about memory overflow of my datastream.
    Here is my code:
    @QDataStream out(&file);
    out.setVersion(QDataStream::Qt_5_2);
    out << _missionsEx.size();
    for(int i=0; i<_missionsEx.size() ;i++)
    {
    out << _missionsEx[i];

    for(int j=0; j< _missionsEx[i]._porte[0]._cylindre.size() ;j++)
    for(int k=0; k< _missionsEx[i]._porte[0]._cylindre[j]._axe.first()._aquisition.size() ;k++)
    {
        if(_missionsEx[i]._porte[0]._cylindre[j]._axe.first()._aquisition[k]._bscan.isNull())
                qDebug()<< "NULL" <<_missionsEx[i]._porte[0]._cylindre[j]._axe.first()._aquisition[k]._id;
    }
    

    }@

    My class MissionBDD is pretty big it contains several classes and the class Aquisition contains several images (_bscan) (about 2,5 Mo).
    If I try to write mission which contains 150 images.
    I have 53 images which are really written the others are "White".

    Someone can help me to fix this problem ?
    Thanks

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Francknos
      wrote on last edited by
      #2

      Someone can help me ?

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

        Hi,

        Pretty strange… You could try flushing the QDataStream in between two _missionsEx.

        Also, are you sure that everything is generated correctly ?

        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
        0
        • F Offline
          F Offline
          Francknos
          wrote on last edited by
          #4

          Everything is generated correctly i'm sure because I work with this data.
          I'd like try a "flush" between missions but there is no function flush or something like that in QDataStream.

          thk for your reply.

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

            Sorry, it's in QTextStream.

            One thing you could do is check the status of the stream between two writes

            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
            0
            • F Offline
              F Offline
              Francknos
              wrote on last edited by
              #6

              The status is everytime ok.
              All "missions" are done in the loop but I think the size of data is to big.
              about 1,6 Go in RAM.
              There is no error in writing, it's when I want import these data that the reader write first data (about 50 -55 missions).

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

                32bit application ?

                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
                0
                • F Offline
                  F Offline
                  Francknos
                  wrote on last edited by
                  #8

                  Yes I would like to do in 64 but i used a library in 32.

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

                    I wonder if you're not hitting the 2GB memory limit somehow, but that should rather kill your application AFAIK.

                    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
                    0
                    • G Offline
                      G Offline
                      giesbert
                      wrote on last edited by
                      #10

                      But writing or reading files with more then 2 GB should not hurt unless you allocate everything in memory, shouldn't it?

                      Nokia Certified Qt Specialist.
                      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

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

                        AFAIK, it should not.

                        However I wonder what might happen if you are reaching the limit of available memory without allocating enough to make the OS decide to kill your application.

                        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
                        0
                        • G Offline
                          G Offline
                          giesbert
                          wrote on last edited by
                          #12

                          What about: try it out? :D

                          Nokia Certified Qt Specialist.
                          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                          1 Reply Last reply
                          0
                          • F Offline
                            F Offline
                            Francknos
                            wrote on last edited by
                            #13

                            Hi Thanks for your reply,

                            For information, I think the OS block the use of memory at about 2Go.
                            I have a lot of memory (64Go). But my application use 1.6Go at maximum.

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

                              It's because your application is 32bit, the max memory size it can use is 2GB even if you computer had terabytes available

                              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
                              0

                              • Login

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