Win32::Process load_file:Insufficient system resources exist to complete the requested service

StackOverflow https://stackoverflow.com/questions/21189673

  •  29-09-2022
  •  | 
  •  

Question

We have a perl scrip that runs builds for our sourcecode (C++). We have a line similar to the following:

Win32::Process::Create($ProcessObj,"$COMSPEC",$cmd,0,NORMAL_PRIORITY_CLASS,".")|| die ErrorReport();

We make this call several times throughout our build process - during one of the final times, we get the following error:

Can't load 'C:/Program Files (x86)/IBM/RationalSDLC/common/lib/perl5/site_perl/5.8.6/MSWin32-x86-multi-thread/auto/Win32/Process/Process.dll' for module Win32::Process: load_file:Insufficient system resources exist to complete the requested service at C:/Program Files (x86)/IBM/RationalSDLC/common/lib/perl5/5.8.6/MSWin32-x86-multi-thread/DynaLoader.pm line 230.

We have several builds running at the same time, which could explain the resource issue, except that these schedules have been in place for roughly ~2.5 years, with little or no issues. I can't find anything related to this issue - could anyone here provide some assistance?

Was it helpful?

Solution

I was wondering why you're using an ancient copy of Perl, then I realize you're using IBM Rational products-- maybe even ClearCase Now, I feel your pain.

The obvious answer is that your Perl script is eating away at memory each time it calls Win32::Process:Create. This is especially true if the old process hasn't yet died before calling a new process. If you look at the Task Manager you should be able to see the resources get eaten away with each call.

Why are you getting this issue now and not before? Maybe your builds are getting more complex or taking longer to complete. Before, maybe builds were completing while you were spawning new ones.

You can use Activity Monitor to watch memory and other resources, or download the Sysinternals tools from Microsoft which will allow you to dig deeper into the issue.

You can take a look at the Event Viewer and see if there's anything else it will tell you.

There are two recommendations I can make:

  • Use a newer version of Perl. It might be that your version of Perl has some sort of memory leak. You can download a more recent version of Perl which might help. The issue is if you are using Rational tools, you can't get rid of the old one. You can install the two versions in two different places, but you will have to make sure you are using the correct version.
  • Another possibility is to switch to using Jenkins as your build tool instead of using your Perl script.

Jenkins is easy to install, and gives you a lot more options in controlling your build process. The default way (and it's not that Jenkins is setup to do it this way as much as this is how most people use it) is to fire off a build each time a change is made. However you can do this manually, by a certain time of day, or even by hitting a particular URL. The last is convenient when you want to fire off a dozen or so builds at the same time. A single script can do this for you.

The big advantage is that Jenkins will queue the builds, so not to overwhelm the resources of your build system. For example, you could have 3 or 4 build executors, and only 3 or 4 builds will be executed at the same time. Any other build you fire off will simply wait for the next free executor. You can have as few as a single executor, or as many as... I've had up to 16 at one time.

It'll probably be easy to switch to using Jenkins. Jenkins takes about 10 to 20 minutes to setup (and I'm including downloading Jenkins from the Internet in that too.) Setting up a build project is fast, and you can probably use the same command you're using to fire off the build too. If this is a .NET project, you can download the MSBuild plugin for Jenkins too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top