Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page files (virtual memory)

Status
Not open for further replies.

hag99

Technical User
Nov 8, 2003
49
US
For a very long time I have had a problem with my app using too much virtual memory (VM). After much testing I find that when the app runs a zero divide it uses page file space wich controls VM. I have many zero devides in the many calculations the program makes. All work fine but I'd like to reset the page files to a lower number after the zero divide runs so as to prevent running out of VM. I know I can set a "what if" clause to stop running the zero devide calc but toooo much code to go through. Any function or suggestions on how to solve this with out have to find the may zero devides and going with the "what if" clauses. Looking for code that releases the number of page files used. Help.
 
I'm a little confused by your posting.

From how I read it you expect to control the memory footprint of an application in the clipper code its self?

That can only be done by recompiling using a dynamic compiler. I use blinker for this reason, it does a great job managing memory usage and has plenty of features to configure VMM if needed. I've found the defaults to work great.

What exactly is your application doing that needs to be fixed? Are you exhausting memory and crashing? Or are you getting divide by zero execution errors? Those are not necessarily the same.

You can have a divide by zero error from a logic error in your code or the VMM can report one when it has exhausted all memory.

Maybe you could reply with the exact error you are getting.

Lyndon
 
Thanks for your response. The program is a clipper back end program converted to windows useing Fivewin. clipper 5.2 and blinker 7. As the program dues a zero divide it uses more page files. Thus if there are many zero divides the it will have to use more and more page files until the VM needs to be changed (XP does it automatically, increasing the size of the VM which reduces the speed of the program.) If there is a way to reset the page files downward after a zero divide, getting rid of the page file no longer needed then XP will not be required to reset the VM or number of page files and the program will not become sluggish..

Make any more sense?

Harvey
 
when a number is divided by a zero.

nNumber := 100
nNumber1 := 0

ie... nNumber/nNumber1

Number is being devide by zero.
 
I usually test for those before doing the calculation...

Code:
nNumber  := 100
nNumber1 := 0
if nNumber1 <> 0
  nResult = nNumber/nNumber1
else
  nResult = 0
endif

So, that means I've not come across the problem!

Regards

Griff
Keep [Smile]ing
 
You could do something using a BEGIN SEQUENCE and trapping the zero-divide, by generating a BREAK in the errorhandler when a divide by zero-error occurs, it would be like this (quote from the original Cl5.2 Norton Guide):
Code:
bLastHandler := ERRORBLOCK({    |objErr| MyHandler(objErr, .T.)})
BEGIN SEQUENCE
   .
   . <operation that might fail>
   .
RECOVER USING objLocal
   .
   . <send messages to objLocal and handle the error>
   .
END
// Restore previous error handler
ERRORBLOCK( bLastHandler )

FUNCTION MyHandler( objError, lLocalHandler )
   // Handle locally returning the error object
   IF lLocalHandler
      BREAK objError
   ENDIF
   .
   . <other statements to handle the error>
   .
   RETURN NIL

HTH
TonHu
 
The above advice is just what you need if your application is trying to divide by zero.

Memory management is not your problem.
 
There must already be an error handler in place which is handling the zero divide exception, otherwise the program would be crashing.

If zero divides are causing increased memory usage then the problem would be that the zero divide error handler is not properly cleaning up after the error and releasing working storage.

Offhand it is difficult to imagine how this is happening, but unless you are using some library which is providing the error recovery from zero division then the answer should be there in your code. If not, then TonHu's suggestion about writing your own would seem to be the way to go.

Alternatively, replacing all the divisions in your app with a call to a UDF incorporating a zero divisor test as Griff suggests should be pretty easily done on a global search and replace basis.

Jock
 
Thanks for all ofyour help. Griffs is the way to go but many zero divides in the program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top