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. Memory of QRC files - too big
Qt 6.11 is out! See what's new in the release blog

Memory of QRC files - too big

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 588 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.
  • B Offline
    B Offline
    Brad1111
    wrote on last edited by
    #1

    Hello everyone,

    I have a deep question about memory management of PYQT with images, using the qrc files.
    Let me give the details below.
    The Raw images I want to add in my program in .jpg format : Total Size : 150 MB.
    The QRC File : 1KB
    The PY File after converting it with QRC. Total Size : 370 MB.
    (I can compile it for a size reduction but I doesnt change anything for the last step which is my issue)
    Memory My program takes once running, and not importing the image File : 99 MB
    Memory My program takes once running, and importing the image File (py) : 1.08GB.

    Can anyone help me understand how and why do my images go from about 150mb to almost 1000 MB ?
    Its just a program with buttons, a few frames, and images used as background in frames.

    Thanks

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

      Hi,

      How many images are you using ?
      What size are they ?
      One thing you might not have taken into account is that in order for an image to be shown, it must be uncompressed so for a 4k image with 8bit per channel:

      3840 x 2160 (image size) x 3 (number of channels) 
      

      It's about 24MB per image. It can go update to 32 if using an image format that supports alpha.

      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
      • B Offline
        B Offline
        Brad1111
        wrote on last edited by
        #3

        @SGaist Thank you very much ! You are absolutely right. I took one random image I have, one that is 3000x7000 with 32 bit depth and apparently the uncompressed size is about 10 times the size shown in the system, which explains perfectly that gap I noticed between the compressed size and the memory it loads.

        I suppose the only way to tackle this issue would be to reduce either the resolution or the bit depth of the image, prior to loading it into the qrc ?

        artwawA 1 Reply Last reply
        0
        • B Brad1111 has marked this topic as solved on
        • B Brad1111

          @SGaist Thank you very much ! You are absolutely right. I took one random image I have, one that is 3000x7000 with 32 bit depth and apparently the uncompressed size is about 10 times the size shown in the system, which explains perfectly that gap I noticed between the compressed size and the memory it loads.

          I suppose the only way to tackle this issue would be to reduce either the resolution or the bit depth of the image, prior to loading it into the qrc ?

          artwawA Offline
          artwawA Offline
          artwaw
          wrote on last edited by
          #4

          @Brad1111 As usual, the sensible approach is to pack the largest size you might need but also to consider cache or even on-the-fly resizing prior to showing, where applicable of course.
          Other way is to see if any of your images would benefit from being vector based (i.e. svg) than bitmap - it is very often possible for line art, icons and such. Small size, virtually unlimited and unaffected quality of resizing.

          For more information please re-read.

          Kind Regards,
          Artur

          1 Reply Last reply
          2
          • B Offline
            B Offline
            Brad1111
            wrote on last edited by
            #5

            @artwaw Thank you for your insight Artur. I will try to resize my images and also check the details on SVG as you suggested. I barely knew this format existed!

            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