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. QPixmap memory leak issue
Qt 6.11 is out! See what's new in the release blog

QPixmap memory leak issue

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.1k Views 2 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.
  • R Offline
    R Offline
    RamK
    wrote on last edited by JKSH
    #1

    when I create QPixmap and call delete and check the memory allocation it show memory leak.
    Please find the code snippet below,

    _CrtMemState memAtStart;
    _CrtMemCheckpoint( &memAtStart );
    
    QPixmap *pix = new QPixmap(":/ActiveImage");
    delete pix;
    _CrtMemState memAtEnd
    _CrtMemCheckpoint( &memAtEnd );
    _CrtMemState memDiff;
    if ( _CrtMemDifference( &memDiff, &memAtStart, &memAtEnd)){
        _CrtMemDumpStatistics( &memDiff );
        FAIL()<< "memoryleak detected";
    }
    

    Event I tried calling QPixmapCache:: remove() and clear() methods , However still it shows memory leak.

    Please let me know when the memory will get cleared.

    [EDIT: Updated code formatting --JKSH]

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      deleting a piece allocated memory doesn't mean it will go back directly to the OS. You have an interesting article here about memory management

      By the way QPixmap is an implicitly shared class so you rarely need to allocate it on the heap

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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