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. Limit Heap size

Limit Heap size

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.8k 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.
  • QT-static-prgmQ Offline
    QT-static-prgmQ Offline
    QT-static-prgm
    wrote on last edited by
    #1

    Hello,

    I'm looking for a way to limit the heap size of an c++ project. I use the Qt Creator, so i wonder if there is maybe an option that can set the maximum size of the heap, or maybe there is a c++ command that can do it.

    So why do i need it:
    I want to force other developers to use the delete command, after they used the new command to allocate an object on the heap.

    So it's about an custom list class. The heap should has just enought space to store about 5 list elements. If you want to add an other element you need to delete one of the entry and NOT just delete the pointer of the last next pointer to decrease the list size.

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      No need to make it difficult! Make sure they setup the QObject parent correctly. QObject uses a lightweight reference counter. When nothing (pointer is deleted) is referencing to the QObject it will get deleted for you!
      So it add a bit of C++ extra to it.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • QT-static-prgmQ Offline
        QT-static-prgmQ Offline
        QT-static-prgm
        wrote on last edited by
        #3

        That's an nice work around. But the project should teach programming, so i wanted an example where it is necessary to delete the created objects.
        My idea was to limit the heap, so that only about 5 elements can be reserved. if you want an other element you need to delete an existing one first.

        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