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. Invalid parameter passed to C runtime function
QtWS25 Last Chance

Invalid parameter passed to C runtime function

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtcreatorqstringlistruntime error
19 Posts 3 Posters 10.1k Views
  • 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.
  • M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 9 Nov 2017, 11:26 last edited by
    #2

    @Lasith said in Invalid parameter passed to C runtime function:

    std::bad_alloc

    That is normally when you run out of memory :)

    Check the mem use of your app.

    L 1 Reply Last reply 9 Nov 2017, 11:57
    1
    • L Lasith
      9 Nov 2017, 11:21

      When I run my code of my Qt C++ application I get the following error! What can be the main reasons for such an error?
      "Invalid parameter passed to C runtime function.
      terminate called after throwing an instance of 'std::bad_alloc'
      what(): std::bad_alloc"

      J Offline
      J Offline
      JonB
      wrote on 9 Nov 2017, 11:31 last edited by
      #3

      @Lasith
      Check your calls to "std::alloc", i.e. everywhere you allocate memory. If you do inadvertently do something which boils down to, say:

      size_t size = (size_t) -1;
      std::alloc(size);
      

      then you will have memory problems :)

      L 1 Reply Last reply 9 Nov 2017, 12:00
      0
      • M mrjj
        9 Nov 2017, 11:26

        @Lasith said in Invalid parameter passed to C runtime function:

        std::bad_alloc

        That is normally when you run out of memory :)

        Check the mem use of your app.

        L Offline
        L Offline
        Lasith
        wrote on 9 Nov 2017, 11:57 last edited by
        #4

        @mrjj You mean Hard disk or main memory?

        M 1 Reply Last reply 9 Nov 2017, 12:00
        0
        • L Lasith
          9 Nov 2017, 11:57

          @mrjj You mean Hard disk or main memory?

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 9 Nov 2017, 12:00 last edited by
          #5

          @Lasith

          Main memory.
          the new function can trow that error if you try to allocate and there is not enough free.

          http://en.cppreference.com/w/cpp/memory/new/bad_alloc

          L 1 Reply Last reply 9 Nov 2017, 14:00
          1
          • J JonB
            9 Nov 2017, 11:31

            @Lasith
            Check your calls to "std::alloc", i.e. everywhere you allocate memory. If you do inadvertently do something which boils down to, say:

            size_t size = (size_t) -1;
            std::alloc(size);
            

            then you will have memory problems :)

            L Offline
            L Offline
            Lasith
            wrote on 9 Nov 2017, 12:00 last edited by
            #6

            @JNBarchan I already have this issue :O

            1 Reply Last reply
            0
            • M mrjj
              9 Nov 2017, 12:00

              @Lasith

              Main memory.
              the new function can trow that error if you try to allocate and there is not enough free.

              http://en.cppreference.com/w/cpp/memory/new/bad_alloc

              L Offline
              L Offline
              Lasith
              wrote on 9 Nov 2017, 14:00 last edited by
              #7

              @mrjj so how can I increase the amount of memory?

              M 1 Reply Last reply 9 Nov 2017, 16:06
              0
              • L Lasith
                9 Nov 2017, 14:00

                @mrjj so how can I increase the amount of memory?

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 9 Nov 2017, 16:06 last edited by mrjj 11 Sept 2017, 16:10
                #8

                @Lasith
                Add more memory to the pc.
                But how much does the target currently have ?
                Did you check the how much app uses etc?

                Or find out if you are leaking memory and hence it runs dry.
                You have to find out what causes it using the debugger.
                Step through the code to find out where or in what context the
                error comes.

                You have not shown any code so its not possible to guess at.

                L 1 Reply Last reply 9 Nov 2017, 16:10
                3
                • M mrjj
                  9 Nov 2017, 16:06

                  @Lasith
                  Add more memory to the pc.
                  But how much does the target currently have ?
                  Did you check the how much app uses etc?

                  Or find out if you are leaking memory and hence it runs dry.
                  You have to find out what causes it using the debugger.
                  Step through the code to find out where or in what context the
                  error comes.

                  You have not shown any code so its not possible to guess at.

                  L Offline
                  L Offline
                  Lasith
                  wrote on 9 Nov 2017, 16:10 last edited by
                  #9

                  @mrjj Thanx how can I check the current memory usage? Using the task manager?

                  M 1 Reply Last reply 9 Nov 2017, 16:11
                  0
                  • L Lasith
                    9 Nov 2017, 16:10

                    @mrjj Thanx how can I check the current memory usage? Using the task manager?

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 9 Nov 2017, 16:11 last edited by
                    #10

                    @Lasith
                    Yes it can give a good hint. Start app and see how much it uses.

                    there is also
                    https://docs.microsoft.com/en-us/sysinternals/downloads/rammap

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 9 Nov 2017, 16:12 last edited by
                      #11

                      Does error comes as soon as you start the app or
                      does it take some time?

                      L 1 Reply Last reply 9 Nov 2017, 16:16
                      0
                      • M mrjj
                        9 Nov 2017, 16:12

                        Does error comes as soon as you start the app or
                        does it take some time?

                        L Offline
                        L Offline
                        Lasith
                        wrote on 9 Nov 2017, 16:16 last edited by Lasith 11 Sept 2017, 16:17
                        #12

                        @mrjj The error oocurs when I click a button which feeds a set of values to a QStringList through 2 for loops!

                        M J 2 Replies Last reply 9 Nov 2017, 16:22
                        0
                        • L Lasith
                          9 Nov 2017, 16:16

                          @mrjj The error oocurs when I click a button which feeds a set of values to a QStringList through 2 for loops!

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 9 Nov 2017, 16:22 last edited by
                          #13

                          @Lasith
                          Ok, you might copy a lot around and run out of memory.
                          is it 32/64 bit app?
                          how much memory do you have?

                          L 1 Reply Last reply 9 Nov 2017, 16:24
                          0
                          • M mrjj
                            9 Nov 2017, 16:22

                            @Lasith
                            Ok, you might copy a lot around and run out of memory.
                            is it 32/64 bit app?
                            how much memory do you have?

                            L Offline
                            L Offline
                            Lasith
                            wrote on 9 Nov 2017, 16:24 last edited by
                            #14

                            @mrjj I can not check now :( Its in my office PC Now I am home I will notify you tomorrow! :)

                            M 1 Reply Last reply 9 Nov 2017, 16:25
                            0
                            • L Lasith
                              9 Nov 2017, 16:24

                              @mrjj I can not check now :( Its in my office PC Now I am home I will notify you tomorrow! :)

                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 9 Nov 2017, 16:25 last edited by
                              #15

                              @Lasith
                              Ok, if you copy lists, it might be the reason.
                              You should show the code.
                              Using all mem with strings, takes a lot of strings :)

                              1 Reply Last reply
                              0
                              • L Lasith
                                9 Nov 2017, 16:16

                                @mrjj The error oocurs when I click a button which feeds a set of values to a QStringList through 2 for loops!

                                J Offline
                                J Offline
                                JonB
                                wrote on 9 Nov 2017, 16:31 last edited by
                                #16

                                @Lasith said in Invalid parameter passed to C runtime function:

                                @mrjj The error oocurs when I click a button which feeds a set of values to a QStringList through 2 for loops!

                                And you're sure those 2 loops aren't actually unlimited? ;-) Better look at how many iterations they do :) You do have to do really quite a lot of iterations to run out of memory!

                                L 1 Reply Last reply 9 Nov 2017, 16:40
                                1
                                • J JonB
                                  9 Nov 2017, 16:31

                                  @Lasith said in Invalid parameter passed to C runtime function:

                                  @mrjj The error oocurs when I click a button which feeds a set of values to a QStringList through 2 for loops!

                                  And you're sure those 2 loops aren't actually unlimited? ;-) Better look at how many iterations they do :) You do have to do really quite a lot of iterations to run out of memory!

                                  L Offline
                                  L Offline
                                  Lasith
                                  wrote on 9 Nov 2017, 16:40 last edited by Lasith 11 Sept 2017, 16:40
                                  #17

                                  @JNBarchan No the upper limits of the conditions is finite! Any way I will check and see! Plus if its an infinite loop the error message is different as I remember!

                                  J 1 Reply Last reply 9 Nov 2017, 16:42
                                  0
                                  • L Lasith
                                    9 Nov 2017, 16:40

                                    @JNBarchan No the upper limits of the conditions is finite! Any way I will check and see! Plus if its an infinite loop the error message is different as I remember!

                                    J Offline
                                    J Offline
                                    JonB
                                    wrote on 9 Nov 2017, 16:42 last edited by JonB 11 Sept 2017, 16:43
                                    #18

                                    @Lasith said in Invalid parameter passed to C runtime function:

                                    @JNBarchan No the upper limits of the conditions is finite!

                                    This is good to know. But there are finite numbers and then there are other finite numbers. Numbers like, say, 0x7FFFFFFF (2 billion?) as the limit in each loop (I'm understanding they are nested?) will cause a lot of iterations... ;-)

                                    L 1 Reply Last reply 9 Nov 2017, 16:54
                                    1
                                    • J JonB
                                      9 Nov 2017, 16:42

                                      @Lasith said in Invalid parameter passed to C runtime function:

                                      @JNBarchan No the upper limits of the conditions is finite!

                                      This is good to know. But there are finite numbers and then there are other finite numbers. Numbers like, say, 0x7FFFFFFF (2 billion?) as the limit in each loop (I'm understanding they are nested?) will cause a lot of iterations... ;-)

                                      L Offline
                                      L Offline
                                      Lasith
                                      wrote on 9 Nov 2017, 16:54 last edited by
                                      #19

                                      @JNBarchan yeah they are nested for loops!

                                      1 Reply Last reply
                                      0

                                      11/19

                                      9 Nov 2017, 16:12

                                      • Login

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