Re: Need help with "out of memory Errors" on server script
Re: Need help with "out of memory Errors" on server script
- Subject: Re: Need help with "out of memory Errors" on server script
- From: Bryan <email@hidden>
- Date: Mon, 17 Sep 2001 23:21:21 -0400
- Organization: Apex Radiology
The way I fixed this problem was to create a recursive script which performed no
function except
to check if the main script was running and to start it if it wasn't. Then I
limited the number of cycles
that the main script would perform before quitting. This resets the memory for the
main application
at every quit and the overflow is never reached.
Granted this is a kluge, but it is effective.
Bryan Kaufman
Steven Angier wrote:
>
"John R. Head" wrote:
>
>
> I have an application that is running constantly watching folders and
>
> depending on file type, doing some work on them and communicating results
>
> via URL ACCESS to an app on WebObjects.
>
>
>
> We are getting this error message "out of memory" after an extended period
>
> of this application watching folders. We have played with settings and all
>
> to no avail.
>
>
AppleScript applications have memory leaks. One of the more common ways to run
>
in to them is by trapping errors in try/on error blocks.
>
>
My tests have shown a net memory loss of 1 bit for every 15 or so errors
>
trapped (see the test code below). This is a very strange amount. Maybe the
>
Apple people (Chris) can explain the how and why (and hopefully plug the leak).
>
>
> There are 2 folders it watches, and one folder has 10 inside of it. But if
>
> it has been about 3 hours or so (I guess since we never can see it actually
>
> produce the error,) but only when we come in the AM is it showing this
>
> message. There is an Idle routine and about 15 pages of scripts that it is
>
> working through till it finds the right kind of file. But there appear to be
>
> no problems there with the script and its memory during its working phase,
>
> only during the idle loops with nothing to do.
>
>
I have found that the most reliable solution is to allocate a seemingly
>
rediculous amount of memory to the application (say 2 MB or more). This gives
>
your script apps a significant leak buffer. I find that this amount of memory
>
keeps the app running for longer than the average uptime on the box/process (3
>
or 4 weeks with many of our processes). This amount of extra RAM will, of
>
course, vary.
>
>
> Is there some way to purge memory, or defragment it so we do not experience
>
> this problem within the script. I have considered quitting the script every
>
> 4th time or so, I do have an AS application that watches to make sure it is
>
> running.
>
>
You could do that, but it will probably be overkill. Similarly, a daily restart
>
of the app or machine may also be overkill and may increase the risk of more
>
downtime due to start-up errors.
>
>
I think that if you give the app enough RAM to keep it going for several weeks,
>
you will find that you never run out of memory because you will probably
>
restart the process or the box within that time.
>
>
Try downloading Memory Mapper by R. Fronabarger from Version Tracker and just
>
monitor the free memory lost in your application over the course of a few hours
>
and days. You can then quantify the actual memory loss and extrapolate the
>
practical amount of memory you should give your applications.
>
>
Good luck,
>
>
Steven Angier
>
Macscript.com
>
_______________________________________________
>
applescript-users mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
[demime 0.98b removed an attachment of type text/x-vcard which had a name of bryan.vcf]