1 /****************************************************************************
3 * SciTech OS Portability Manager Library
5 * ========================================================================
7 * The contents of this file are subject to the SciTech MGL Public
8 * License Version 1.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of
10 * the License at http://www.scitechsoft.com/mgl-license.txt
12 * Software distributed under the License is distributed on an
13 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * rights and limitations under the License.
17 * The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
19 * The Initial Developer of the Original Code is SciTech Software, Inc.
20 * All Rights Reserved.
22 * ========================================================================
28 * Description: Test program to determine just how much memory can be
29 * allocated with the compiler in use. Compile and link
30 * with the appropriate command line for your DOS extender.
32 * Functions tested: PM_malloc()
33 * PM_availableMemory()
36 ****************************************************************************/
55 char *p,*pa[MAXALLOC];
57 printf("Program running in ");
58 switch (PM_getModeType()) {
60 printf("real mode.\n\n");
63 printf("16 bit protected mode.\n\n");
66 printf("32 bit protected mode.\n\n");
70 printf("Memory available at start:\n");
71 PM_availableMemory(&physical,&total);
72 printf(" Physical memory: %ld Kb\n", physical / 1024);
73 printf(" Total (including virtual): %ld Kb\n", total / 1024);
75 for (allocs = i = 0; i < MAXALLOC; i++) {
76 if ((pa[i] = PM_malloc(10*1024)) != 0) { /* in 10k blocks */
78 memset(p, 0, 10*1024); /* touch every byte */
79 *p = 'x'; /* do something, anything with */
80 p[1023] = 'y'; /* the allocated memory */
82 printf("Allocated %lu bytes\r", 10*(allocs << 10));
85 if (PM_kbhit() && (PM_getch() == 0x1B))
89 printf("\n\nAllocated total of %lu bytes\n", 10 * (allocs << 10));
91 printf("\nMemory available at end:\n");
92 PM_availableMemory(&physical,&total);
93 printf(" Physical memory: %ld Kb\n", physical / 1024);
94 printf(" Total (including virtual): %ld Kb\n", total / 1024);
96 for (i = allocs-1; i >= 0; i--)
99 printf("\nMemory available after freeing all blocks (note that under protected mode\n");
100 printf("this will most likely not be correct after freeing blocks):\n\n");
101 PM_availableMemory(&physical,&total);
102 printf(" Physical memory: %ld Kb\n", physical / 1024);
103 printf(" Total (including virtual): %ld Kb\n", total / 1024);