Subject: API memory leaking? Posted: 9/12/2017 Viewed: 7601 times
I am encountering an error which I think is associated with the memory that WEAP is using. The context is that I’m trying to use the API to run a few thousand simulations on a small WEAP model (9 demand nodes, 6 reservoirs, 7 inflow sequences), with each simulation driven by slightly different input conditions. The script reads in the input (inflow and reservoir ET) files, runs WEAP calculations, writes the results to a CSV, and repeats.
The API script seems to work fine initially, but as it loops through the simulations it starts taking up more and more RAM. For instance, when I initially started running it WEAP was using about 50 MB of RAM, but then after a couple hundred simulations it is up to using around 3400 MB, at which point I get an error message from WEAP (usually either about being out of memory or not being able to find a certain database file in the /WORK folder). The machine still has plenty of RAM, so it appears to be an issue with the WEAP software.
Does anyone know any way to deal with this issue? I’m wondering if there is something that I can specify in my script, or some setting within WEAP, that could help to avoid this.
Mr. Jack Sieber
Subject: Re: API memory leaking? Posted: 9/14/2017 Viewed: 7560 times
When you run a script from within WEAP, either from the menu item Advanced/Scripting/Run, from the Script Editor, or from an Event Script, each call to the WEAP API consumes a small amount of RAM. For very long scripts, or those that iterate many times, this can result in running out of memory.
Running a script outside of WEAP does not consume memory, so in this case, the solution for you is to run your script directly, rather than inside WEAP. If you double-click on the vbs script file from Windows Explorer it will run the script.
Note: When you run a script outside of WEAP, you need to add the following line as the first line of the script, so that the Windows Scripting engine knows where to find WEAP:
Set WEAP = CreateObject("WEAP.WEAPApplication")
Dr. Julie Shortridge
Subject: Re: API memory leaking? Posted: 9/18/2017 Viewed: 7550 times
That seems to be working. Thank you!