Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7764151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:50:17+00:00 2026-06-01T14:50:17+00:00

Is there a way to set a maximum memory usage for a 64 bit

  • 0

Is there a way to set a maximum memory usage for a 64 bit application?

Reason: when a 64 bit .net algorithm/application running on my laptop exceeds memory requirements of 3 GB, my computer gets really slow. (Stays slow after I manually terminate the program.) I would rather have the algorithm terminate when it is exceeding 3GB.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:50:19+00:00Added an answer on June 1, 2026 at 2:50 pm

    You could check the Process.WorkingSet64 Property.

    var currentProcess = System.Diagnostics.Process.GetCurrentProcess();
    if(currentProcess.WorkingSet64 > 3221225472)
        throw new System.OutOfMemoryException("Process memory consumption exceeded 3GB");
    

    If you want to limit the memory without checking it, because you’re calling external API’s, you could use JobObjectWrapper. It allows you to create a process and limit the amount of memory this process can use.

    JobObjectWrapper is a .NET abstraction over the Win32 Job Object. With
    this library you can create job objects, create and assign a process
    to the job, control process and job limits, and register for the
    various process- and job-related notification events.

    Edit: from the sample project:

    class Program
    {
        static bool _isStop = false;
    
        static void Main(string[] args)
        {
            try
            {
                using (JobObject jo = new JobObject("JobMemoryLimitExample"))
                {
                    jo.Limits.JobMemoryLimit = new IntPtr(30000000);
                    jo.Events.OnJobMemoryLimit += new jobEventHandler<JobMemoryLimitEventArgs>(Events_OnJobMemoryLimit);
    
                    while (!_isStop)
                    {
                        ProcessStartInfo psi = new ProcessStartInfo("calc.exe");
                        Process proc = jo.CreateProcessMayBreakAway(psi);
                        Thread.Sleep(100);
                    }
                }
            }
            catch (Exception){ }
        }
    
        /// <summary>
        /// The events which fires when a job reaches its memory limit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        static void Events_OnJobMemoryLimit(object sender, JobMemoryLimitEventArgs args)
        {
            _isStop = true;
            (sender as JobObject).TerminateAllProcesses(8);
            Console.WriteLine("Job has reacehed its memory limit");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to set the maximum CPU usage for a process in
I was just wondering if there is an elegant way to set the maximum
Is there any way to set a maximum size of a Collection in Java?
Is there a way to set the maximum zoom level on a UIImageView?
Can I set a maximum fps? Is there any way to limit fps in
Is there way to set @include mixin(); to variable? I tried this @mixin bg-gradient($fallback,
Is there a way set flags on a per-file basis with automake? In particular,
Is there any way to set the same icon to all my forms without
Is there a way to set a different value for service startup timeout per
Is there a way to set the StartPosition of a Windows Forms form using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.