Utility for clearing RAM to the hard drive. - OS2

This is a discussion on Utility for clearing RAM to the hard drive. - OS2 ; Jim Moe wrote: > Paul Ratcliffe wrote: >>>> But the program is almost completly pointless! It just forces something to occur >>>> earlier that would otherwise occur later - i.e. the paging out of unreferenced >>>> memory. >>> Not really. ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 21 to 28 of 28

Thread: Utility for clearing RAM to the hard drive.

  1. Re: Utility for clearing RAM to the hard drive.

    Jim Moe wrote:
    > Paul Ratcliffe wrote:
    >>>> But the program is almost completly pointless! It just forces something to occur
    >>>> earlier that would otherwise occur later - i.e. the paging out of unreferenced
    >>>> memory.
    >>> Not really. Especially if it is run as the last thing at startup.

    >> All it would seem to do to me is force a load of possibly pointless swapping.
    >> How does this thing know how much memory to allocate? You have to allocate
    >> more memory than you have to force some swapping, but how do you know where
    >> to draw the line? [...]
    >>

    > Here's the whole program:
    > /* **
    > build with: g++ -Wall -Zexe -Zomf allocmem.c allocmem.def
    > ** */
    >
    > #define MODERN
    > #define INCL_BASE
    > #define INCL_DOS
    > #include
    >
    > #include
    > #include
    > #include
    > #include
    > #include
    >
    > #include
    > #include
    > #include
    > #include
    >
    > #define PAGESIZE 4096L
    >
    > int i;
    > ULONG n;
    >
    > void (* sig_segv_old)(int);
    > void sig_segv_handler (int signum)
    > {
    > fprintf(stderr, "?Segment violation, out of range memory access, bad
    > stuff like that.\n");
    > fprintf(stderr, " Occurred when the memory value became %ld on the
    > %dth page\n", n, i);
    > exit (signum);
    > }
    >
    >
    > int main (int argc, char **argv)
    > {
    > void * baseptr;
    > char * ptr;
    > char * bptr;
    > ULONG n1;
    > ULONG physmem_resmem[2];
    > APIRET rc;
    >
    >
    > sig_segv_old = signal(SIGSEGV, &sig_segv_handler);
    >
    > rc = DosQuerySysInfo(QSV_TOTPHYSMEM, QSV_TOTRESMEM, &physmem_resmem,
    > sizeof(physmem_resmem));
    > switch (rc)
    > {
    > default:
    > case 0: break;
    > case 87: fprintf(stderr, "Invalid Parameter\n"); break;
    > case 111: fprintf(stderr, "Buffer Overflow\n"); break;
    > }
    > if (0 != rc)
    > exit(0);
    >
    > if (argc != 2)
    > n = physmem_resmem[0] - physmem_resmem[1];
    > else
    > {
    > /* round up to 4K page */
    > n = (1024L * atoi(argv[1]) + 4095L) & 0xFFFFF000;
    > if (0 == n)
    > {
    > printf("?[%d] is an invalid value\n", atoi(argv[1]));
    > puts("Usage: allocmem [# of K]\n" );
    > exit(1);
    > }
    > }
    >
    > printf("Physical Memory %ld K, Resident Memory %ld K\n",
    > physmem_resmem[0] / 1024L, physmem_resmem[1] / 1024L);
    >
    > rc = DosAllocMem(&baseptr, (n), PAG_COMMIT | PAG_WRITE);
    >
    > /* Hunt for an amount to allocate that is legal. */
    > if (8 == rc)
    > {
    > // If not enough memory, decrease allocation until there is. Binary search.
    > n1 = n;
    > do {
    > n1 = n1 / 2;
    > if (8 == rc)
    > {
    > n -= n1;
    > rc = DosAllocMem(&baseptr, (n), PAG_READ);
    > }
    > else // 0 == rc
    > {
    > n += n1;
    > rc = DosFreeMem(baseptr);
    > rc = DosAllocMem(&baseptr, (n), PAG_READ);
    > }
    > } while (PAGESIZE < n1);
    >
    > if (0 == rc)
    > rc = DosFreeMem(baseptr);
    > else
    > n -= n1;
    > rc = DosAllocMem(&baseptr, (n), PAG_COMMIT | PAG_WRITE);
    > }
    > printf("Allocating %ld K... ", n / 1024L);
    >
    > switch (rc)
    > {
    > default:
    > case 0: break;
    > case 8: fprintf(stderr, "Not Enough Memory\n"); break;
    > case 87: fprintf(stderr, "Invalid Parameter\n"); break;
    > case 95: fprintf(stderr, "Interrupted system call\n"); break;
    > }
    > if (0 != rc)
    > exit(0);
    >
    > bptr = (char *) baseptr;
    > ptr = bptr + (n - PAGESIZE);
    > i = 0;
    > do
    > {
    > ++i;
    >
    > *ptr = 0; /* Force it to allocate */
    > ptr -= PAGESIZE; /* Move to the next page. */
    > DosSleep(0);
    > }
    > while (bptr <= ptr);
    >
    > printf("\n");
    >
    > exit (0);
    > }
    >
    >
    > The DEF file:
    >
    > NAME ALLOCMEM WINDOWCOMPAT
    > PROTMODE
    > DATA MOVEABLE
    > CODE MOVEABLE PURE
    > STACKSIZE 1524288
    >
    >


    Also watch out for the line wrapping around line 29
    Dave

  2. Re: Utility for clearing RAM to the hard drive.

    Paul Ratcliffe wrote:
    >
    >> os/2 seems to load a number of DLLs at startup that are not used again.

    >
    > Which DLLs would they be then? And how did you tell?


    I'm presuming that is what is left in memory after startup. I have no
    precise measurements but there is 30 - 60 MB of RAM that is recovered that
    is never swapped back in after running allocmem.
    Certainly forcing all pages of memory to disk slows down startup both
    during the program run and after to swap back in what is actually needed
    after startup is finished. Recovering at least 30 MB of RAM is worth it to me.

    --
    jmm (hyphen) list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)

  3. Re: Utility for clearing RAM to the hard drive.

    On Fri, 7 Sep 2007 05:36:56 UTC, Jim Moe
    wrote:

    > Paul Ratcliffe wrote:
    > >
    > >> os/2 seems to load a number of DLLs at startup that are not used again.

    > >
    > > Which DLLs would they be then? And how did you tell?

    >
    > I'm presuming that is what is left in memory after startup. I have no
    > precise measurements but there is 30 - 60 MB of RAM that is recovered that
    > is never swapped back in after running allocmem.
    > Certainly forcing all pages of memory to disk slows down startup both
    > during the program run and after to swap back in what is actually needed
    > after startup is finished. Recovering at least 30 MB of RAM is worth it to me.


    But you're not 'recovering' it, are you? Those pages will be pushed out
    anyway when the space is actually needed. Let the natural paging
    mechanisms do the work.


  4. Re: Utility for clearing RAM to the hard drive.

    Trevor Hemsley wrote:
    > On Wed, 5 Sep 2007 10:51:23 UTC in comp.os.os2.apps, Nobody
    > wrote:
    >
    >> Oooh, perhaps it is time for another great author to improve upon this
    >> program, just as you have described. Hint, hint. (s)

    >
    > But the program is almost completly pointless! It just forces something to occur
    > earlier that would otherwise occur later - i.e. the paging out of unreferenced
    > memory.
    >

    Yes. And that is all. But, I think it should be done when the system is
    *not* busy. OS/2 can and does do this when it is busy, but it doesn't
    seem to clean-up itself (such as its OS2*.INI files) on a regular basis
    in preparation for something that is coming-up in the future.

    I liked having the the unwanted paged-out in advance.

    IBM wrote that this is what they designed into OS/2 Warp 3.0, and
    pointed out that uses would notice a much larger swap file just after
    OS/2 began. I thought that was bad idea at the time. But, now with hard
    drive space available (and RAM too), I think it is a good idea.

    And I like to do it when OS/2 is not actively busy, but just before it
    is going to get busy, such as in the beginning, and before running
    "large" programs such as Mozilla/Seamonkey, etc.


  5. Re: Utility for clearing RAM to the hard drive.

    Trevor Hemsley wrote:
    > On Thu, 6 Sep 2007 20:09:25 UTC in comp.os.os2.apps, Nobody
    > wrote:
    >
    >> Trevor Hemsley wrote:

    snip
    >>>

    >> Trevor you wrote such a utility.

    >
    > It's true that I wrote something but it was never intended for this purpose. It
    > never pretended that it was a good thing to force everything out into the
    > swapfile, just that it would do so. Reading the description I wrote shows that,
    > but I have to admit that I don't remember what I thought it was doing at the
    > time I wrote that readme!
    >

    It is of some historical interest and historical review these days. We
    can't believe how far we have come, and the public still wants more!
    Including OS/2 users!

    A sign of genius I think. I don't know. I can't remember. (s)

    >> These days I do get a error from it:
    >> 4OS2.EXE
    >>
    >> A program generated an access violation at 00010460.
    >> MEMOS2.EXE 0001:00000460

    >
    > That's because it was written in the days (11 years ago!) when 128MB RAM was a
    > gigantic amount and far more than most users were using. It never even occurred
    > to me that we'd see machines with such prodigious amounts of RAM installed that
    > it would exceed OS/2's (old) 512MB limit per process. It's crashing because the
    > amount of physical memory is now greater than the amount available in the
    > private arena < 512MB. It could be fixed but frankly I don't think it's worth it
    > - the program was really written to stress test my system and there are better
    > alternatives available today that don't need an o/s at all (memtest86 and
    > memtest86+).
    >

    I agree that memtest86+/memtest86 are excellant choices. But, they are
    not OS/2 programs. It has been a gem for some years. I always hope that
    you will continue to develop your work.


  6. Re: Utility for clearing RAM to the hard drive.

    In <6LqdnWXbka3kfn3bnZ2dnUVZ_o-mnZ2d@giganews.com>, on 09/06/2007
    at 10:36 PM, Jim Moe said:

    Hi,

    > I'm presuming that is what is left in memory after startup. I have no
    >precise measurements but there is 30 - 60 MB of RAM that is recovered
    >that is never swapped back in after running allocmem.


    Odd. What is this conclusion based on?

    I built your app and added a 10 second delay before the exit so I could
    capture some data with Thesues while the app was active. This results in
    the following on a system with 512MB of physical RAM

    Before:

    Free, Idle, and Locked Memory:
    Free RAM = 188A8000 bytes (402080K) (392.656M). Idle
    RAM = 000BA000 bytes ( 744K) ( 0.727M).
    (Dirty idle RAM = 000A9000 bytes ( 676K) ( 0.660M)).
    Long Term Locked RAM = 00101000 bytes ( 1028K) ( 1.004M).
    Short Term Locked RAM = 00000000 bytes ( 0K) ( 0.000M).
    Short & Long Locked RAM = 00000000 bytes ( 0K) ( 0.000M).

    During:

    Free, Idle, and Locked Memory:
    Free RAM = 07E4D000 bytes (129332K) (126.301M). Idle
    RAM = 000B6000 bytes ( 728K) ( 0.711M).
    (Dirty idle RAM = 000A5000 bytes ( 660K) ( 0.645M)).
    Long Term Locked RAM = 00101000 bytes ( 1028K) ( 1.004M).
    Short Term Locked RAM = 00000000 bytes ( 0K) ( 0.000M).
    Short & Long Locked RAM = 00000000 bytes ( 0K) ( 0.000M).

    After:

    Free, Idle, and Locked Memory:
    Free RAM = 188A6000 bytes (402072K) (392.648M) Idle
    RAM = 000BA000 bytes ( 744K) ( 0.727M).
    (Dirty idle RAM = 000A9000 bytes ( 676K) ( 0.660M)).
    Long Term Locked RAM = 00101000 bytes ( 1028K) ( 1.004M).
    Short Term Locked RAM = 00000000 bytes ( 0K) ( 0.000M).
    Short & Long Locked RAM = 00000000 bytes ( 0K) ( 0.000M).

    Before:

    Analysis of the SWAPPER.DAT file:
    There are 512 disk frames in SWAPPER.DAT (each is 4K bytes). There are
    1 frames used. (4K => 0.004M)
    There are 511 frames free. (2044K => 1.996M)
    There are 512 frames total. (2048K => 2.000M)

    After:

    Analysis of the SWAPPER.DAT file:
    There are 512 disk frames in SWAPPER.DAT (each is 4K bytes). There are
    0 frames used. (0K => 0.000M)
    There are 512 frames free. (2048K => 2.000M)
    There are 512 frames total. (2048K => 2.000M)

    As you can see nothing ever gets written to the swap file.

    To really use all of the available physical RAM, you need to make the app
    linger and spawn sufficient process instances so that the available
    physical RAM is put in use.

    Steven

    --
    --------------------------------------------------------------------------------------------
    Steven Levine MR2/ICE 3.00 beta 08pre #10183
    eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
    --------------------------------------------------------------------------------------------


  7. Re: Utility for clearing RAM to the hard drive.


    Nobody wrote in message <46e05f13@kcnews01>...
    >
    >FWI, once I was able to get the proper name of the utility that I was
    >thinking of (which is, PAGEOUT.EXE), I found that in this group some
    >time back, one write wrote that the author is Andrew Belov.


    weirdness

    >But, now
    >text file with such information is provided with the program.


    does it work now

    mk5000

    John Anderton: That's all, huh? Just walk right into Precrime, go into the Temple, somehow tap into the Precogs, and then download
    this Minority Report...
    Dr. Iris Henimen: If... you have one.



  8. Re: Utility for clearing RAM to the hard drive.

    On Thu, 06 Sep 2007 22:36:56 -0700, Jim Moe
    wrote:

    >>> os/2 seems to load a number of DLLs at startup that are not used again.

    >>
    >> Which DLLs would they be then? And how did you tell?

    >
    > I'm presuming that is what is left in memory after startup. I have no
    > precise measurements but there is 30 - 60 MB of RAM that is recovered that
    > is never swapped back in after running allocmem.


    What you're really saying is that you're guessing because you have no concrete
    evidence to back up your assertions.

    > Certainly forcing all pages of memory to disk slows down startup both
    > during the program run and after to swap back in what is actually needed
    > after startup is finished.


    Great. You think this is an improvement?

    > Recovering at least 30 MB of RAM is worth it to me.


    Bollocks. What are you going to use it for? How do you know when it is being
    used? How do you know that what you did to 'free up' this memory couldn't
    be better done by the operating system?

    How much physical RAM have you got anyway? If it's more than 512MB then, as
    Steven has pointed out, you are most likely not having any effect anyway
    running this pointless utility.

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2