No announcement yet.

How to start program Minimized as to show less memory usage in Task Manager?

  • Filter
  • Time
  • Show
Clear All
new posts

    Guys --
       #Compile Exe
       #Include ""
       Function PbMain () As Long
          Local hDlg As Long
          Dialog New 0, "Test", , , 100, 100, %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
          Dialog Show State hDlg, %SW_MINIMIZE
          Dialog Show State hDlg, %SW_RESTORE
          Dialog Show Modal hDlg
       End Function
    Win200: 280 K. If dialog is invisible - 156 K (w/o %SW_RESTORE)

    E-MAIL: [email protected]

    [This message has been edited by Semen Matusovski (edited November 10, 2000).]



      The way I tested the "Stack Reserve","Stack Commit" parameters some years
      ago was to run many instances of a test program to see if effected the
      total memory usage in a linear manner, it didn't.

      Next test was to run a large number of different programs to see if the
      memory usage was linear, it wasn't.

      The Portable Executable standard is the same across the range of 32 bit
      Microsoft operating systems from win95 up and NT4/Win2k so the same things

      As a side hobby I write small memory footprint editors and the single
      factor relevant is the amount of code in the application and the amount of
      memory that they allocate on the fly. Effectively the stack parameters do
      not matter.

      The things that you would normally look at in memory usage terms are code
      size, memory allocation and deallocation and make sure that you don't have
      any memory leaks with GDI and similar functions. Track transient memory
      usage to ensure that you don't have overlapping allocations that are not
      needed and deallocate when the memory is no longer needed, not at the end
      of the proc.

      I understand what both Eric and Semen are after with the NT specific APIs
      but I see them as extra code and processor time for no purpose. The binary
      generated by the PowerBASIC compilers is very efficient if the code is
      written properly and that is simply more efficient than covering up a
      trivial reading.


      [email protected]

      hutch at movsd dot com
      The MASM Forum - SLL Modules and PB Libraries


        Steve, thanks very much for taking the time to write that, I always learn something from what you publish here. As an assembly guru you're looking at the program source and seeing code that basically shouldn't be there, and I hear ya big fella! But hardly any of my customers would care if there was an invisible dialog window that they didnt even know about, especially when it has virtually no impact on the running of the program - I'm only trying to look at this from the perspective of a would-be customer who decides to see how much memory my program is using by using good old Task Manager ... sure it's a coverup, and it seems that we have to create a window just to do that coverup, its crazy! But my customers will probably actually be happier?
        But, my program is a UDP Server/invisible daemon kind of thing for LANs. It needs to have an invisible window anyway so that it can receive messages, so in this particular case, im not actually creating an extra window to do the mem-usage-coverup, im just using that same window...
        anyway while im here id like to thank everyone for their time in testing this, seems there are new questions to be answered though



          I was using these three lines, and they were doing the trick perfectly... until I tried to start Photoshop and/or mirc!
          The instant i kill my process, photoshop/mirc will spring back to life

          Dialog New 0, "", , , 0, 0, %WS_SYSMENU + %WS_MINIMIZEBOX To hDlg
          Dialog Show State hDlg, %SW_MINIMIZE
          Dialog Show State hDlg, %SW_HIDE
          Comment those three lines out, recompile it, and it runs fine and Photoshop/mirc also load fine... (except Task Manager now shows 1200kb+ memory usage instead of 5-700kb)


          Using Visual Studio 6's process viewer, my program (without the 3 Dialog lines) showed:
          Working Set: 1060kb
          Heap Usage: 180kb
          With the 3 window lines in...
          Working Set: 528kb
          Heap Usage: 180kb

          Compared to Notepad.exe ... in normal state:
          Working Set: 1372kb
          Heap Usage: 152kb
          Working Set: 92kb
          Heap Usage: 152kb

          am i feeling slightly envious? well, yes...



            Well that suggests a couple of things to try.

            1. The apps you mentioned may also use a hidden window, so you may need to actually assign some caption text to the dialog window to distinguish your hidden window from other windows.

            2. Your app is not providing a message pump, so although you have created a Window, there is nothing to occuring to actually service the message queue.

            Why not try starting this dialog as a separate thread and explicitly starting the dialog as a modal dialog... that way the message queue will be serviced, so when another app tries to send a message like %WM_GETTEXT, the message is processed.

            Alternatively, recreate your app to work "inside" the callback for the hidden window... triggered either as a %WM_USER message, or as a separate thread.

            This will obviously add a bit to the overall memory consumption, but it may still give you the results you are looking for (the "appearance" of minimal memory consumption).

            My $0.02...

            PowerBASIC Support
            mailto:[email protected][email protected]</A>
            mailto:[email protected]


              > the "appearance" of minimal memory consumption

              You could also phrase that "a truer indication of memory consumption".

              -- Eric

              Perfect Sync: Perfect Sync Development Tools
              Email: mailto:[email protected][email protected]</A>
              "Not my circus, not my monkeys."