Results 1 to 4 of 4

Thread: Qt 5 stack memory limit?

  1. #1
    Join Date
    Feb 2013
    Posts
    65
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Qt 5 stack memory limit?

    I’m using Qt 5.1 32 bit for VS2012. My application has a class that gets instantaniated when I press a button on the main form. The class has large arrays. When I try to run the program, it crashes. When I decrease the array sizes by 10 to 1, for example, no problems. The large arrays are for data calculations, Here are the array sizes:

    array1 [100000×4]
    array2 [10000×5]
    array3 [1000×6]
    array4 [100×7]
    array5 [50×8]

    Will using the 64 bit Qt 5 solve my problem?

    I have ported the same program from C# in Visual Studio 2013 compiled for 32 bit, and the code works fine there. I don’t know why Qt would be different.

    I’m using Windows 7 SP1 64 bit with 8 GB ram.

    Any help would be appreciated. Thanks in advance.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt 5 stack memory limit?

    This is not a Qt problem but C++ compiler. Maybe this article helps.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt 5 stack memory limit?

    We have no idea what size each of these objects in your array is. 400000 bytes is a very different beast to 400000 doubles (3.2MB) or 400000 10kbyte QPixmaps. We can only assume that they are stack allocated but that is also not specified. The default stack size limit in VC++ is 1MB from memory. The stack limit could be avoided by heap allocation but a 32 bit executable on Windows also has a 3 gigabyte absolute limit on the program memory space. It is also possible you do not have a size problem but an out-of-bounds problem that trashes the program stack causing whatever the unspecified error is.

    It is possible that just using QVector or a similar container will avoid the problem without imposing manual memory management on you.

  4. #4
    Join Date
    Feb 2013
    Posts
    65
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default [Solved] Qt 5 stack memory limit?

    I solved the problem by adding a line to my .pro file:

    QMAKE_LFLAGS_WINDOWS += -Wl,--stack,32000000

    for minGW 32 bit compiler

    and

    QMAKE_LFLAGS += /STACK:32000000

    for msvc 32 bit compiler.

    Runs lightening fast. Only adds 2 MB of memory in Task Manager.

    Thanks for the replies.
    Last edited by te777; 1st November 2013 at 00:47. Reason: Mark as solved

Similar Threads

  1. Syncing QTextDocument's undo stack with custom undo stack
    By Dini Selimović in forum Newbie
    Replies: 0
    Last Post: 24th June 2012, 13:11
  2. Replies: 33
    Last Post: 10th June 2010, 16:51
  3. how to fing the stack memory size ?
    By john_god in forum General Programming
    Replies: 2
    Last Post: 17th June 2009, 01:30
  4. limit memory allocation
    By magland in forum General Programming
    Replies: 10
    Last Post: 23rd March 2007, 09:21
  5. stack
    By mickey in forum General Programming
    Replies: 7
    Last Post: 20th November 2006, 14:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.