Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt android one activity ?

Qt android one activity ?

Scheduled Pinned Locked Moved Mobile and Embedded
androidactiviry
7 Posts 2 Posters 2.6k 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.
  • musimbateM Offline
    musimbateM Offline
    musimbate
    wrote on last edited by
    #1

    Hello,
    I am working on a android app using Qt and I have found that the amount of RAM consumed by the app keeps growing as we add new features (code) on the project.
    From what I have been reading on the android documentation I found that an android app is split into different activities and activities not in the foreground may be cleaned by the system .

    Since Qt android apps live in one activity ,all my code lives in one activity and my RAM consuption is growing to unacceptable levels.Is there a way I can split my app into different activities ?Or should I try to pinpoint my problems somewhere else?

    I am fairly new to the android world and I might be trying to find the problem in a wrong place.Any input will help.

    Thank you for your time.

    Why join the navy if you can be a pirate?-Steve Jobs

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

      Hi,

      The first thing I would do is check what makes the RAM consumption go up like that. If it sky-rockets then there might be leaks or bad memory management done (of course it could also be completely legitimate)

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

        @SGaist ,thanks for the reply,
        Memory leaks are most probably contributing to this problem.I run the project througH valgrind and it reported some memory leaks which I still have to learn how to backtrace and knock down.
        My app also uses lots of QStacked widgets loaded with other widgets .

        I took a minimal widget application and added code like this at the end of the constructor to kind of simulate what is happening in my app to have an idea.

        for (int i=0;i<4200;i++)
            {
                CustomWidget * mWidget=new CustomWidget(this);
                ui->stackedWidget->addWidget(mWidget);
        
            }
        

        The consumed RAM increased by 40MB on my android armeabiv7 device compared to the minimal widget app.

        The app doesn't obviously have that many stackedWidgets but I increased the number to account for the contents and data within those stacked widgets.It was designed like this to allow fast switching between pages but It looks like we need to find another way without sacrificing lots of RAM.Any thoughts or advice?

        Why join the navy if you can be a pirate?-Steve Jobs

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

          How many widgets are you creating ? And are you re-creating them ? If so are you deleting the originals ?

          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
          • musimbateM Offline
            musimbateM Offline
            musimbate
            wrote on last edited by
            #5

            The widgets are being created dynamically when the app is running ,the number is not fixed .But it is save to assume a couple of hunderds for busy users of our app.Is it possible to have an estimate of the amount of RAM consumed by the allocation of one empty Qt widget?

            Also a side note ,could you know if there is a way to know which part of the app is consuming move RAM?I read about valgrind and I can spot memory leaks but it could help to know which part of the app is swallowing my RAM so I know where to start optimizing.

            Another problem I think I have is trying to use the Qt desktop app development mindset to mobile devices .Is there a place one can learn about a few guidelines for developping android (mobile) apps using Qt ?

            Thank you for your time.

            Why join the navy if you can be a pirate?-Steve Jobs

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

              You can use KDAB's GammaRay to analyze your application.

              However there's one thing that's intriguing me, why so much widgets ?

              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
              • musimbateM Offline
                musimbateM Offline
                musimbate
                wrote on last edited by
                #7

                GammaRay is a good tool ,but I ended up using valgrind and the problem with our app was in the desing ,having tons of (some times useless) widgets in memory at the same time.We are redesigning our user interface now instead of trying to fix a bad design.The design was done using only Qt Widgets mostly because of a lack of expertise in mobile development and QML in particular.We hope QML will ease some of the troubles we came across :-)

                Why join the navy if you can be a pirate?-Steve Jobs

                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