The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation


Q & A: How do I Make AlwaysUp Babysit my “Leaky” VB6 Program?

Q & A - Memory leak
  Our old VB6 program leaks memory on every request and it can fail or crash multiple times a day. We need to re-write it but we don’t have budget right now so I’m looking at AlwaysUp to run it all the time. What settings should I use to keep it running?

— Anonymous

Hi. We have many customers who have turned to AlwaysUp to keep legacy applications going. Here is what we recommend for your situation:

Restart your VB6 program on high memory use

AlwaysUp is designed to launch your application as a Windows Service when your computer boots, but it can perform several “monitoring tasks” after that initial event.

One such task is to watch how much memory your application is using. You can setup AlwaysUp to stop and restart your application when its memory usage crosses a specific threshold.

The setting is available on AlwaysUp’s Monitor tab:

AlwaysUp Monitor tab - Memory setting

The default threshold is 512 MB. Is that too much (or too little) for your VB6 application?

We suggest using the Task Manager to get an idea of how much memory your application typically consumes. Use that information to set the threshold appropriately.

Note: Because AlwaysUp is a 32-bit application, the maximum memory threshold you can set is 4 GB. You will have to configure the CheckMemorySize64 sanity check plugin to exceed that limit. Please get in touch if you need help doing that.

Preempt memory problems by restarting VB6 (or rebooting the PC) once per day

While restarting on high memory is a good safety net, it is unpredictable. Your customers may notice a brief interruption if a restart occurs at a busy time.

Consider instead, a proactive daily restart — to flush the accumulated memory leaks and start your VB6 program afresh. With a clean slate, your application should run reliably for some time before the excessive leaks bog it down again.

You can configure a daily restart on the Monitor tab as well. Here we have asked AlwaysUp to stop and restart the application every day at 2 AM:

AlwaysUp Monitor tab - Daily restart

Note that you can:

  • Reboot the entire machine. This may be necessary if you find that restarting the application alone doesn’t clear the problems.
  • Restart/reboot only when certain conditions are met. For example, you can skip the restart if the application is busy (i.e. using CPU), or if it hasn’t used much memory yet.

Whatever works for your situation!

Want to restart your Visual Basic program more than once per day? This article reviews some alternatives.

Those two settings should help. Best of luck with your application!

Posted in AlwaysUp | Tagged , , , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *