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. Total size of allocated memory by container
QtWS25 Last Chance

Total size of allocated memory by container

Scheduled Pinned Locked Moved General and Desktop
containersmemory managmen
2 Posts 2 Posters 1.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.
  • P Offline
    P Offline
    Peppy
    wrote on last edited by
    #1

    Is there any way how to know the total amount of memory allocated by containers like QList? I wish I had an option to be able to have information about, just to compute how many things I can stick into some memory limit. I can closely estimate memory usage for basic containers like QList (which seems to be double-linked list) or QVector, but not the other containers.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      In general no. QList is not really a linked list (QLinkedList is). It is a sorta vector-list hybrid that allocates chunks of the data as contiguous arrays. How many chunks there are, what is their overhead size, does it hold pointers to elements or optimizes small sized items by holding them in place, what is the alignment overhead - these are all implementation details that affect the size and there's no reliable way to estimate them, or even if you did, they might change in future versions.

      1 Reply Last reply
      1

      • Login

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