[comp.sys.ibm.pc.rt] Memory usage on the RT.

mark@quintus.UUCP (Mark Spotswood) (09/08/89)

I am working on a large application which performs its own memory management.
When I run this application, I use up all of the swap space on the machine and
AIX kills the process. I am using ulimit() to determine the maximum possible
break point. The problem is that ulimit() returns the total amount of swap
space on the machine and I am allowed to set the break point to that value.
Then I start writing to the space, and eventually all of the page space gets
used up. When this happens, AIX sends a SIGDANGER signal and kills the process.
I have a signal handler, but it is unable to react in time to prevent the
process from being killed. 

Is there any way to find out how much swap space is actually left while running,
so that I can set the break point to a more reasonable value and avoid being
killed?

I am running AIX 2.2.1 on an RT model 125.

Any help with this problem would be greatly appreciated.

-- mark

drake@ibmarc.uucp (Sam Drake) (09/10/89)

In article <1247@quintus.UUCP> mark@quintus.UUCP (Mark Spotswood) writes:
>Is there any way to find out how much swap space is actually left while running,
>so that I can set the break point to a more reasonable value and avoid being
>killed?

Look at the "monitor" program, shipped with IBM's X11 product as a sample.
Among other things, it will display a real-time graph of the amount of
page space available; presumably you can use the same technique in your
application.

Sam Drake / IBM Almaden Research Center 

johnny@edvvie.at (Johann Schweigl) (09/15/89)

From article <1247@quintus.UUCP>, by mark@quintus.UUCP (Mark Spotswood):
> Is there any way to find out how much swap space is actually left while running,
> so that I can set the break point to a more reasonable value and avoid being
> killed?

VRM provides the information you want in the data segment of the process.

	.
	.
	.
	volatile int *freePages = (int *)0xbc;
	.
	.
	printf("number of free 2K pages in pagespace is %d\n",*freePages);
	.
	.

The volatile int declaration prevents reads to *freePages from being optimized
away by the -O option.
*freePages is modified by the VRM at unpredictable rates (unpredictable as far
as the application program is concerned).

Hope it helps. Bye,
-- 
       ------------------------------------------------------------------
       EDV Ges.m.b.H Vienna              Johann Schweigl    
       Hofmuehlgasse 3 - 5               USENET: johnny@edvvie.at
       A-1060 Vienna, Austria      Tel: (0043) (222) 59907 257 (8-19 CET)

johnny@edvvie.at (Johann Schweigl) (09/15/89)

Sorry, iv'e misread the adress in my manuals. The correct code is

	volatile int *freePages = (int *)0xb8;

apologize for it,
-- 
       ------------------------------------------------------------------
       EDV Ges.m.b.H Vienna              Johann Schweigl    
       Hofmuehlgasse 3 - 5               USENET: johnny@edvvie.at
       A-1060 Vienna, Austria      Tel: (0043) (222) 59907 257 (8-19 CET)