Announcement

Collapse
No announcement yet.

Is It Possible To Guarantee A Program's Running Memory Size

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is It Possible To Guarantee A Program's Running Memory Size

    this may seem like a strange question, but if a person wanted to guarantee a program to have x amount of memory available for the running program, could a person do it.

    reason for question.
    you want to guarantee that a program does not run out of memory because the program is a critical program and finishing a certain task is a must.
    as we all know, there is not way to force a user to not be running other programs or tasks taking up main and swapped memory. the program we write may need some large arrays.

    paul
    thanks in advance
    p purvis

  • #2
    You can always allocate the memory before any changes. Then start the task only
    and ONLY if the memory could be allocated. If the amount of memory is unknown...
    there are no warraties, but you can play slightly safer with a big RAM PC.

    Comment


    • #3
      Provided the swap file is enabled, Windows should always allow your app to get the full 2 GB+ a 32-bit process can access. The amount of onboard RAM is immaterial. Look up the "About Memory Management" topic in your win32.hlp.
      Last edited by Kev Peel; 1 Feb 2008, 06:40 AM.
      kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

      Comment


      • #4
        SetProcessWorkingsetSize () in your WinAPI reference.

        But before you play with that, I really suggest you both follow the reading suggestions and at the same time, add this memory usage report to your target application and study the results:
        Add Process Memory Usage Report to any program 1-12-04

        That report will help you understand what you are reading about.

        (It's all of two lines of code to add it, one of which is an #INCLUDE statement. I done good when I wrote that).

        [lLATER]
        Darned, another one of those funky conversions to the new BBS software.

        You'll need to change this:
        Code:
        $psapi_getprocessmemoryinfo  = "getprocessmemoryinfo"
        To
        Code:
        $psapi_getprocessmemoryinfo  = "GetProcessMemoryInfo"
        [/LATER]

        MCM
        Last edited by Michael Mattias; 1 Feb 2008, 12:28 PM. Reason: Added note re funky conversion
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          >the program we write may need some large arrays.

          Why not use a work file on disk? No need to use up RAM is there? Then your program only has to worry about how much hard disk you have, plus you can now handle MORE THAN the 2 GB RAM limitation.

          (Silver spoon? Nah, must have been born with 2Gb of RAM at your disposal. But you'd have thought of this yourself if you had done a lot of work in the days of 640Kb max.).


          MCM
          Last edited by Michael Mattias; 1 Feb 2008, 12:06 PM.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            640 Kb ???

            Wow 640 Kb !

            I started programming on a "pre-PC" machine that had 16 Kb
            I even used a machine with 8 Kb once and it had a nice FORTRAN compiler on it. Of course it did not waste any RAM on a GUI since you fed it punch cards.

            The next generation of programmers will probably wonder what to do when they cannot allocate that terra-byte of RAM as an array.

            But to be serious -- we should learn from the past and balance previous constraints that required more design elegance with better resource availability today -or- in pragmatic terms: "Just because you have RAM does not mean it is or is not the best solution. Examine the problem from many angles, understand your constraints and requirements, then find a good solution."
            Mark Strickland, CISSP, CEH
            SimplyBASICsecurity.com

            Comment


            • #7
              >> I even used a machine with 8 Kb once

              You were spoiled. I started on a ZX81 with 1k RAM...
              (Later got a 16kB extension pack)
              Regards,
              Peter

              Comment


              • #8
                Originally posted by Peter Lameijn View Post
                >> (Later got a 16kB extension pack)
                Bet it cost you about 6 months pay or somewhere thereabouts.
                There are no atheists in a fox hole or the morning of a math test.
                If my flag offends you, I'll help you pack.

                Comment


                • #9
                  And some of even started with computers only had 6 bits to a byte

                  Comment


                  • #10
                    Sorry, deleted content not appropiate for thread
                    Last edited by Nick Luick; 5 Feb 2008, 02:42 AM. Reason: Wrong for forum thread

                    Comment


                    • #11
                      if you had done a lot of work in the days of 640Kb max.).

                      >> (Later got a 16kB extension pack)

                      Wow 640 Kb !

                      I started programming on a "pre-PC" machine that had 16 Kb

                      I even used a machine with 8 Kb once

                      And some of even started with computers only had 6 bits to a byte

                      You were spoiled. I started on a ZX81 with 1k RAM...

                      ...
                      Mine is smaller than yours! Nyahda nyahda nyah da!
                      It's a pretty day. I hope you enjoy it.

                      Gösta

                      JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                      LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                      Comment


                      • #12
                        thanks for those replies,
                        i have not had access to the internet over the last week
                        paul
                        p purvis

                        Comment


                        • #13
                          >Provided the swap file is enabled...

                          Just for the record, I had this come up over the summer when I was in beautiful downtown Columbus MS. (Home of the PigFest). (Nothing quite like Mississippi in August!).

                          Client had been having sproradic - and of course, unreproducible - problems with applications halting with a "Cannot load RPC [Remote Procedure Call] Library" error messages (a Windows' error message). This required restarts, re-dos and un-dos... very very expensive halts, as this box was a server for all "EDI" applications.

                          We started digging around, and found that although the server in question was running proceeses using a total of 5-6 GB (just adding up what we saw in Task Manager), the system was defined with a "max swap file size" of only 4 Gb.

                          Since we were both in over our heads at this point, we asked the 'systems' guy to take a look ... he reset the swap file to allow Windows to manage the swap file size.

                          No more errors since August.

                          Just a little something to check out next time you get "weird, impossible" errors like this.

                          MCM
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            > have not had access to the internet over the last week

                            Actually I am more interested in how you decide (have decided?) to handle your original memory concerns.

                            Since you are one of the few, the not too proud, the careful who actually gave this issue some thought, then asked here because you weren't sure, I think the results of your thought process would be of interest to the new (and some number of the not-so-new as well).

                            MCM
                            Michael Mattias
                            Tal Systems (retired)
                            Port Washington WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #15
                              still pondering the situation over.


                              I had been writing in cb86 which had memory only 64k for code and 64k for variables and non-gui interface. We changed software vendors 18 months ago from what we had been using since 1983 and in 1985 gave the vendor the boot and i have been in house supporting the databases. Now with the new vendor the, databases are less in number and larger in size. I am moving over to powerbasic, so now i can write programs with more variable memory space.
                              Employees at locations are not computer savy and i saw a program written the other day by the new vendor bust because of not enough memory, but the program was only a 16bit program.

                              It would be nice to load some of the large files in memory but i have seen programs such as microsoft access in years past come to a complete halt due to memory limitations.

                              I have always felt that a program using large amounts of memory was poorly written anyways.

                              I have pondered the idea of
                              Setting a specific amount of free memory to be available upon program startup.
                              Starting a gui program that would be forced on top of the screen with a warning to the user not to start other applications and have that program monitor memory, display the amount of memory in some understandable way and monitor text files that would indicate a second programs completeness that was started by the first gui program that was doing the monitoring.

                              Also the program that would be processing the database would have to be written to handle data in specifically sized sections.

                              You just never know what somebody is going to try and pull on you and i am always the one that pays the price to fix up screw ups.

                              Just another thought, you could actually kill the explorer program so a user would have a hard time starting another program also.
                              Then restart the explorer program once the programs have completed.

                              paul
                              p purvis

                              Comment


                              • #16
                                It would be nice to load some of the large files in memory ...
                                That's not always such a good idea because...
                                I have always felt that a program using large amounts of memory was poorly written anyways
                                .. your feeling is CORRECT!

                                Subjective opinion? Don't worry about all the memory management stuff, other than avoiding the obvious cases where you are loading all kinds of stuff to memory. Win/32 will do a heck of good job for you if you just let it.

                                If you run into snags, you can always post specific questions here and someone will give you ideas.

                                Here's a thread where I had to do a bunch of stuff because I tried to put too much in memory... no, I wasn't even close to the Win/32 limit, but the client was using a 'scheduler' system which restricted the amount of memory any one "child" process could use.

                                http://www.powerbasic.com/support/fo...ML/003994.html

                                Hmm, that's the old forum URL, let me see if I can find the new forum url...

                                Yup, here it is...

                                http://www.powerbasic.com/support/pb...ad.php?t=20645

                                MCM
                                Michael Mattias
                                Tal Systems (retired)
                                Port Washington WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                • #17
                                  I do believe i have seen code to acquire certain resources. I believe a gui program that monitors the memory, disk space and maybe some anything else that would seem relevant, then the gui stays hidden unless certain limits are reached. The gui program upon seeing limits surpassed would become visible giving the info and warning messages as needed to the operator.

                                  The program could be started prior to certain programs being loaded and possibly killed(unloaded) after the certain program ends.

                                  Our users run large programs often, virtual computer software being the biggest memory user, and maybe at least a general memory monitor with a warning, that can be set at each computer is what i need. Warning would be something like a mild popup warning, then two levels of warning for resources being used even higher, after that mild warning with no popdown until the memory usage is reduced, if you get my drift.
                                  paul
                                  Last edited by Paul Purvis; 15 Feb 2008, 12:51 PM.
                                  p purvis

                                  Comment


                                  • #18
                                    Actually, there is a 'canned' Windows event called LOW_MEMORY (or something like that) which is available to any program without doing anything terribly special.

                                    IIRC the one (huge?) downside of using that is that you, the programmer, don't get to define what "low memory" means. If someone in Redmond thinks it's low, it's low.
                                    Michael Mattias
                                    Tal Systems (retired)
                                    Port Washington WI USA
                                    [email protected]
                                    http://www.talsystems.com

                                    Comment


                                    • #19
                                      Paul,
                                      <<I have always felt that a program using large amounts of memory was poorly written anyways.>>

                                      Using large amounts of memory is very good programming under some circumstances.

                                      Memory is a resource to be used as you see fit. If using a lot of memory solves the problem then using a lot of memory might be the right thing to do. Some jobs need a lot of memory and since memory is thousands of times faster than hard disk you can't always leave the data on disk and get your results in time.


                                      Paul.

                                      Comment


                                      • #20
                                        Yes Michael, it seems like we have to roll our own utilities that you would think microsoft would already have already programmed and made easily available to work with their own os systems.
                                        paul
                                        p purvis

                                        Comment

                                        Working...
                                        X