Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Non-GUI Application with small memory consumption...

Non-GUI Application with small memory consumption...

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsonperformancequestion
22 Posts 5 Posters 4 Views 1 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.
  • M Moak

    Shy Agam wrote:

    even with no more than an empty WinMain() function, it consumes about 1000k of RAM

    Are you sure, how did you measure this?

    My Webchat

    S Offline
    S Offline
    Shy Agam
    wrote on last edited by
    #7

    Using the "Processes" tab in the Task Manager...

    M R 2 Replies Last reply
    0
    • S Shy Agam

      I've created an empty console project, added a new .cpp file, and written the following code:

      #include <windows.h>
      
      void main()
      {
          Sleep(10000);
      }
      

      This simple code uses 600k of RAM... Furthermore, it opens a console window, but I suppose it's possible to hide it...

      R Offline
      R Offline
      rp_suman
      wrote on last edited by
      #8

      In generated code, check which part displays console. Is "windows.h" the only header included or something else? Try not including header except which needed for Win32 API. Best Regards, Suman

      S 1 Reply Last reply
      0
      • R rp_suman

        In generated code, check which part displays console. Is "windows.h" the only header included or something else? Try not including header except which needed for Win32 API. Best Regards, Suman

        S Offline
        S Offline
        Shy Agam
        wrote on last edited by
        #9

        rp_suman wrote:

        In generated code, check which part displays console.

        What do you mean by "In generated code"? Nothing was auto-generated...

        rp_suman wrote:

        Is "windows.h" the only header included or something else?

        Yes, it's the only header included. However, when I included it and linked the project, basetsd.h was automatically added to the project as an external dependency.

        R 1 Reply Last reply
        0
        • S Shy Agam

          Using the "Processes" tab in the Task Manager...

          M Offline
          M Offline
          Moak
          wrote on last edited by
          #10

          If I am not wrong the "Mem Usage" column of the task manager includes shared memory from loaded DLLs.

          My Webchat

          S 1 Reply Last reply
          0
          • S Shy Agam

            rp_suman wrote:

            In generated code, check which part displays console.

            What do you mean by "In generated code"? Nothing was auto-generated...

            rp_suman wrote:

            Is "windows.h" the only header included or something else?

            Yes, it's the only header included. However, when I included it and linked the project, basetsd.h was automatically added to the project as an external dependency.

            R Offline
            R Offline
            rp_suman
            wrote on last edited by
            #11

            Which version of vc++ you are trying? I am not sure, but there may be difference in memory between different versions of vc++(6.0, 7.0 and 8.0).

            S 1 Reply Last reply
            0
            • M Moak

              If I am not wrong the "Mem Usage" column of the task manager includes shared memory from loaded DLLs.

              My Webchat

              S Offline
              S Offline
              Shy Agam
              wrote on last edited by
              #12

              My goal is to make the Mem Usage column display 320k or less...

              M 1 Reply Last reply
              0
              • R rp_suman

                Which version of vc++ you are trying? I am not sure, but there may be difference in memory between different versions of vc++(6.0, 7.0 and 8.0).

                S Offline
                S Offline
                Shy Agam
                wrote on last edited by
                #13

                6.0

                1 Reply Last reply
                0
                • S Shy Agam

                  Using the "Processes" tab in the Task Manager...

                  R Offline
                  R Offline
                  rp_suman
                  wrote on last edited by
                  #14

                  Moak could be right, task manager may show not only the program size but linked DLLs etc.. You make sure, the memory size means runtime memory shown by task manager or just the exe file size. Whats the exe file size? Best Regards, Suman btw, my vc 2005 trial version has been expired, so I could not try, just telling ideas

                  S 1 Reply Last reply
                  0
                  • S Shy Agam

                    My goal is to make the Mem Usage column display 320k or less...

                    M Offline
                    M Offline
                    Moak
                    wrote on last edited by
                    #15

                    Shy Agam wrote:

                    My goal is to make the Mem Usage column display 320k or less...

                    Even though that is not the memory that the application will consume? Who is repsonsible for those requirements, would he consider using a root kit that hides the presence of the process from the task manager? Just kidding... you are misinterpreting the data returned from the task manager. What you see there is something like the size of the virtual address space in use which includes system DLLs... but no empty WinMain() application will use up 320K free system memory, how could an empty program waste multiple KB? See How big is my program[^]. Hope it helps :) /M

                    My Webchat

                    modified on Saturday, March 22, 2008 10:53 AM

                    S 1 Reply Last reply
                    0
                    • M Moak

                      Shy Agam wrote:

                      My goal is to make the Mem Usage column display 320k or less...

                      Even though that is not the memory that the application will consume? Who is repsonsible for those requirements, would he consider using a root kit that hides the presence of the process from the task manager? Just kidding... you are misinterpreting the data returned from the task manager. What you see there is something like the size of the virtual address space in use which includes system DLLs... but no empty WinMain() application will use up 320K free system memory, how could an empty program waste multiple KB? See How big is my program[^]. Hope it helps :) /M

                      My Webchat

                      modified on Saturday, March 22, 2008 10:53 AM

                      S Offline
                      S Offline
                      Shy Agam
                      wrote on last edited by
                      #16

                      Moak wrote:

                      Who is repsonsible for those requirements, would he consider using a root kit that hides the presence of the process from the task manager? Just kidding...

                      Hehe... That was funny... :) There's an existing app which consumes about 300k. It's basically the same as the one I'm supposed to write, but it lacks some basic must-have features/abilities, and needs some improvements... The goal is to keep this kind of memory usage, but improve the app, in order not to "pay a large price" for the improvements...

                      M 1 Reply Last reply
                      0
                      • S Shy Agam

                        I was asked to write the app... It's no me who decide...

                        CPalliniC Offline
                        CPalliniC Offline
                        CPallini
                        wrote on last edited by
                        #17

                        Try (I didn't make a test) to change the STACK linker option [^] that defaults to 1 MB. :)

                        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                        In testa che avete, signor di Ceprano?

                        1 Reply Last reply
                        0
                        • S Shy Agam

                          Moak wrote:

                          Who is repsonsible for those requirements, would he consider using a root kit that hides the presence of the process from the task manager? Just kidding...

                          Hehe... That was funny... :) There's an existing app which consumes about 300k. It's basically the same as the one I'm supposed to write, but it lacks some basic must-have features/abilities, and needs some improvements... The goal is to keep this kind of memory usage, but improve the app, in order not to "pay a large price" for the improvements...

                          M Offline
                          M Offline
                          Moak
                          wrote on last edited by
                          #18

                          Shy Agam, I modified my last answer with a link to an article here on CP. Please have a look. /M

                          My Webchat

                          S 1 Reply Last reply
                          0
                          • R rp_suman

                            Moak could be right, task manager may show not only the program size but linked DLLs etc.. You make sure, the memory size means runtime memory shown by task manager or just the exe file size. Whats the exe file size? Best Regards, Suman btw, my vc 2005 trial version has been expired, so I could not try, just telling ideas

                            S Offline
                            S Offline
                            Shy Agam
                            wrote on last edited by
                            #19

                            It doesn't matter... I was put on certain constraints... I have to enforce them... Maybe I can remove dependencies from my app...(?) According to previous posts, it should affact the MemUsage column...

                            R D 2 Replies Last reply
                            0
                            • M Moak

                              Shy Agam, I modified my last answer with a link to an article here on CP. Please have a look. /M

                              My Webchat

                              S Offline
                              S Offline
                              Shy Agam
                              wrote on last edited by
                              #20

                              I read the article... Thanks...

                              1 Reply Last reply
                              0
                              • S Shy Agam

                                It doesn't matter... I was put on certain constraints... I have to enforce them... Maybe I can remove dependencies from my app...(?) According to previous posts, it should affact the MemUsage column...

                                R Offline
                                R Offline
                                rp_suman
                                wrote on last edited by
                                #21

                                Hi, All the best to solve the problem!! Please let me know when you find solution Best Regards, Suman

                                1 Reply Last reply
                                0
                                • S Shy Agam

                                  It doesn't matter... I was put on certain constraints... I have to enforce them... Maybe I can remove dependencies from my app...(?) According to previous posts, it should affact the MemUsage column...

                                  D Offline
                                  D Offline
                                  David Crow
                                  wrote on last edited by
                                  #22

                                  Shy Agam wrote:

                                  I was put on certain constraints... I have to enforce them...

                                  That's all well and good, but you must use the right tool to measure with. Task Manager is not that tool.

                                  "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups