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. Any way to check size of dynamically allocted array in debug mode?
Forum Update on Monday, May 27th 2025

Any way to check size of dynamically allocted array in debug mode?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 225 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.
  • K Offline
    K Offline
    kitfox
    wrote on last edited by kitfox
    #1

    I have an application that I suspect is reading past the end of a float* buffer. Is there any way to see how many bytes have been allocated to this buffer when I've stopped at a breakpoint?

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Use a std::vector / QVector instead plain memory.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • K kitfox

        I have an application that I suspect is reading past the end of a float* buffer. Is there any way to see how many bytes have been allocated to this buffer when I've stopped at a breakpoint?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @kitfox
        If you mean it's been allocated via e.g. new float[100] or similar, then no. As @Christian-Ehrlicher has said, you would need to use a class like a vector which notes how big the allocation is and contains code to do bounds checking.

        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