Way to purge RAM? VB.net

I was wondering if it's possible to purge/clean the RAM usage on button click?
I want to do it because I have been working for a game that eat lots of RAM.
So I wanted to make a program to clean my RAM.

Thank you!
Kerr Heilee AlmarioAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pallavi GodseSr. Digital Marketing ExecutiveCommented:
Try the below coding in VB.Net -
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;

public static extern bool EmptyWorkingSet(IntPtr hProcess);

    public void Clean()
        // get handle to a process
        Process ThisProcess = Process.GetCurrentProcess();

        // empty as much as possible of its working set
        bool Result = EmptyWorkingSet(ThisProcess.Handle);

Jacques Bourgeois (James Burger)PresidentCommented:
First thing is to make sure that you use memory in a proper way in your program itself.

Do you call Dispose or declare variables in a Using...End Using block on all objects that have a Dispose method? This is particularly important in a program that intensely work with graphic components.

If you use COM components, you might also need to call ReleaseComObject when you have finished with an object.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.