Results 1 to 11 of 11

Thread: limit memory allocation

  1. #1
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question limit memory allocation

    Is there a way to specify the maximum amount of memory an application is allowed to allocate... either programmatically or otherwise?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: limit memory allocation

    under linux you have the 'limit' command (per shell session as far as I remeber).
    Don't know if you have something like that under windows.

  3. #3
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: limit memory allocation

    Could you give example usage? When I type
    > man limit

    for example on my Linux I don't get anything... is it a different command?

    Thanks.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: limit memory allocation

    so its not installed on your system.
    Install it.
    I am sure it will be in your package manager.
    http://www.nada.kth.se/cgi-bin/man?p...s=1&ss=&M=&f=y

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,365
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: limit memory allocation

    I think it should be "ulimit".

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: limit memory allocation

    NAME
    limit, ulimit, unlimit - set or get limitations on the sys-
    tem resources available to the current shell and its descen-
    dents

    No the message is not too short.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,365
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: limit memory allocation

    "ulimit" is builtin into bash, so you don't need any packages to use it

  8. The following user says thank you to wysota for this useful post:

    magland (21st March 2007)

  9. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: limit memory allocation

    I stand corrected!

  10. The following user says thank you to high_flyer for this useful post:

    magland (21st March 2007)

  11. #9
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: limit memory allocation

    Do you think I could use

    void QThread::setStackSize ( uint stackSize )

    to limit the available memory in a cross-platform application?

    But I'm worried about using, say, stackSize = 10 MB for an unsigned integer...

    What does "stackSize" precisely mean anyway?

    P.S. -- Great site!

  12. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,365
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: limit memory allocation

    No, this will only limit the stack, whereas most of the memory is usually allocated on heap.

  13. The following user says thank you to wysota for this useful post:

    magland (23rd March 2007)

  14. #11
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: limit memory allocation

    What does "stackSize" precisely mean anyway?
    Well, just as it is named - the stack size.
    You might want to read about heap and stack.
    http://en.wikipedia.org/wiki/Heap_%28programming%29
    http://en.wikipedia.org/wiki/Stack_frame

  15. The following user says thank you to high_flyer for this useful post:

    magland (23rd March 2007)

Similar Threads

  1. Memory Leak in my Application :-(
    By Svaths in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 19:42
  2. Memory Problem with SIGNALS and SLOTS
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2007, 20:39
  3. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 14:40
  4. vector memory allocation
    By TheKedge in forum General Programming
    Replies: 1
    Last Post: 23rd March 2006, 17:27
  5. Qt 4.1 Memory Leak
    By blackliteon in forum Qt Programming
    Replies: 14
    Last Post: 10th February 2006, 12:47

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.