• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1981
  • Last Modified:

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.
0
lawso
Asked:
lawso
  • 3
  • 2
1 Solution
 
ICaldwellCommented:
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...
0
 
lawsoAuthor Commented:
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.
0
 
ICaldwellCommented:
Make sure you are releasing all objects correctly and disposing objects you call if they are available...  Try to reuse any objects in there you can instead of declaring now objects...

Look into running it as a scheduled task instead of a console app... That way it opens, runs what it needs and closes out....you can set it to do that say every 30 min.... Also you may want to look at if you can run it remotely, perhaps transmit the data via a web service....

Hope this gives you some idea's
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
ICaldwellCommented:
I said declaring now objects... meant to say declaring new objects...
0
 
LMiller7Commented:
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.
0
 
lawsoAuthor Commented:
Thanks ICaldwell and others that commented
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now