Click here to Skip to main content
15,905,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Project: I had Accounting project made in MS Access ADP 2003 project that connects to SQL Server database , Because it is not possible to create a beautiful and modern user interface with animation in Access, I decided to rewrite my program, I want to Convert that project to a project to be able to have fast speed program and have beautiful UI with animation and feature that user be able to change theme of Whole application to Dark or Light so I stated C# WPF.

Project info: C# WPF with .NET Framework 4.7.2 , also I used Material Design for set Dark/Light Theme for WHOLE Application

OS: Windows 10 x64 with 8GB RAM

Codes: Invoice Window ↓



My project has a very high RAM consumption, but now that my project is big,In my MainWindow when I want to load a window, I get the following error:

private void Window_Loaded(object sender, RoutedEventArgs e)
            new HEAD_LST_FROOSH22().Show();


System.OutOfMemoryException: 'Insufficient memory to continue the execution of the program.

What I have tried:

I tried to provide all the data needed to check this error, this is a general error and no one can comment with the summary code. I don't expect anyone to read the entire code, but someone can give an opinion or a clue with a glance.

thanks all

Update :

I create A small C# WPF to Test UI because I was suspected to "Material Design"

so here it is :

Updated 3-Feb-24 6:07am
Graeme_Grant 21-Jun-23 20:15pm    
FYI, Visual Studio is a WPF app. I've worked on very large WPF apps and had no memory issues.

There is not enough information here to give us any idea of what you are doing to cause these memory issues.
Dave Kreskowiak 22-Jun-23 12:27pm    
This isn't anywhere near enough information to tell you anything useful. The best you can do at this point to narrow down the problem is to start the app under the debugger and when it breaks, look at the call stack to see if you're in a recursive problem. Once you get more data, you can start asking questions, but you have to narrow down the problem first.
Dave Kreskowiak 22-Jun-23 12:30pm    
Oh, and nobody is going to click on a pastebin link or any other link that's been shortened. There's no way to tell exactly where that link goes and is, therefore, very untrusted.

It's difficult to say something with this less Information ... but :
8 GB Ram with Win10 is not a lot of Memory because Windwos itself takes up to 5 GB for it's own.
Now it depends on your Application what happens with the rest of the Memory and if it's enough ...
Share this answer
Patrice T 21-Jun-23 17:20pm    
Ralf Meier 21-Jun-23 17:39pm    
Thanks Patrice
Insufficient memory to continue the execution of the program for C# WPF

You barely gave us enough information for wild guesses, but enough for sensible solutions.
Yhe only sensible thing to do is to try on PC with 12GB or 16 GB to see if problen still arise.

W10 is memory hungry, and you to stuff it with anti-malware, it may be perfectly normal that 8GB is enough for W10, anti-malware and other stuff, but not much remain for user apps.

Otherwise, the problem is typical of unmastered recursive code.

Without putting hands on your PC and make measurements to understand what consume memory and how it does, it is impossible to help. T6his kind of activity is generally for professionals and is expensive because of time spent.
Share this answer
To add to what Ralf and Patrice have said ... The only way that the code you show could cause that error message is if this code
private void Window_Loaded(object sender, RoutedEventArgs e)
            new HEAD_LST_FROOSH22().Show();
is part of the HEAD_LST_FROOSH22 class, or the HEAD_LST_FROOSH22 class creates an instance of the current class and unbounded recursion is the result.

Let me try to explain what "unbounded recursion" is: in the real world, you have a job to do - make a cup of tea. But in order to make a cup of tea, you have to boil water, and the person that owns the kettle will only let you have it when you give them ... a cup of tea.
Because you need a kettle to make a cup of tea in order to get a kettle to make a cup of tea, you can never finish the task.

In computing, the same thing happens: method A calls itself (direct recursion)
or it calls method B which calls method A (indirect recursion). Because each time you call a method it uses space on the application stack you very quickly exhaust the whole stack, and you get an "out of memory" error. Stacks are pretty small - only 1MB - so it's very easy to exceed that.

So start by looking at the "whole code" and work out what the relationship between the the calls that contains that code and the HEAD_LST_FROOSH22 class is.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900