Link to home
Start Free TrialLog in
Avatar of lawso
lawsoFlag for Australia

asked on

How to limit the memory usage of a VB.NET process in Win Server 2008

Hi there. I currently host a website with a VPS (Virtual Private Server) which only has 1GB RAM. This limited memory is generally ok, however I need to run an console application (written in VB.NET) which can run at quite a high memory usage.

I don't need the console application to run fast... just to run all the way through without dying prematurely, having reached the machine's RAM limit.

As the server is a VPS I don't think I can make use of hard drive space to substitute for RAM (page file).

Instead, I'm hoping there is a way to limit the amout of RAM that the process uses, either through a Windows Server 2008 setting or somehow through the VB.NET code that the console application is written in.

Any advice greatly appreciated.
Avatar of ICaldwell
ICaldwell
Flag of United States of America image

The Memory usage displayed in Task Manager is not correct for VB.net applications...  Your usage is probably very low, the displayed amount is the Working Set which includes shared memory... If other applications request memory then .net will give it back.

Here is an article on it:  http://www.itwriting.com/dotnetmem.php

Basically there is not much you can do about it...  If you create applications in native C++ then you can use the memory tab in task manager to monitor the memory usage...
Avatar of lawso

ASKER

The problem is that it is running on VPS Container that shutsdown Services when the memory spike above the amount allocated to the VPS, even if the amount is not correct.
ASKER CERTIFIED SOLUTION
Avatar of ICaldwell
ICaldwell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I said declaring now objects... meant to say declaring new objects...
As ICaldwell mentioned, there really isn't much an application can do to influence it's memory usage. In Windows physical memory is completely managed by the system, not the application. Task Manager does not show this but RAM will be used to the fullest possible extent, no matter how much or little might be running. Free memory is a great evil in a modern OS. Memory is dynamically assigned to running processes according to their needs and RAM availability. Like RAM, the pagefile is managed by the system and cannot be used directly by applications. What Task Manager shows as "Available" memory DOES NOT impose a limit on what applications may still be run, only on how well they will perform. Your console app should run, even if available memory is low. If necessary, the system will take memory from other processes to meet it's needs. This is a routine and completely normal situation.
Avatar of lawso

ASKER

Thanks ICaldwell and others that commented