|
I have the following statement in a C# 2008 windows application that was converted to a console application:
finally
{
Console.ReadLine();
Environment.Exit(1);
}
<pre>
The error message that is displayed says there is not enough io memory.
Can tell show me in code and/or point me to a reference that will show me how to solve this problem?
|
|
|
|
|
Quote: The error message that is displayed says there is not enough io memory
The code you pasted here has no relation to the error message. It might be other part of your code creating this error. debug your application and run line by line and see on executing which method this error popsup.
also copy the complete exception stack here so that we can able to tell something from that.
|
|
|
|
|
Change the exit code: 0 indicates success, any other number is an error code. Exactly how the error code is interpreted depends on the environment the application is run under - I suspect that your app returning "1" is being interpreted as an I/O error.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
The program that is executed is called by a C# 2010 windows application (called app1) that was converted from a console application.
The following is an example of some of the calls made from app1 to the C# 2008 application that is having the memory problem called app2.
string[] SubPkgIDs = rData.details.Where(c => c.Package_ID.StartsWith("SUB").Select(c => c.PackID).Distinct().ToArray();
foreach (string SubPkgID in SubPkgIDs)
{
{
Process eProcess = new Process();
String Process_Arguments = null;
eProcess.StartInfo.UseShellExecute = false;
e_Process.StartInfo.FileName = "app2.exe";
Process_Arguments = " 3 " + SubPkgID;
eProcess.StartInfo.Arguments = Process_Arguments;
eProcess.Start();
eProcess.WaitForExit(1800);
eProcess.Dispose();
Process_Arguments = null;
}
}
I think the line of code that is causing the memory problem possibly is the following:
eProcess.WaitForExit(1800);
App1 is not waiting for a response basically from app2.exe program that is being called. It waits the 1800 *.secs and makes
the next calls. There is no reason for app1 to wait or app2 to finish executing since it does not need a response from app2.
However if this is causing the memory problem I can wait for the app2 program to finish executing.
App1 and app2 were setup to be single threaded.
In the app1 program that calls the second program called app2, I am thinking of putting the following code at the end of the program:
foreach (Process proc in Process.GetProcessesByName("app2"))
{
proc.Kill();
}
This way the app2 processes that are still in memory can be released.
Thus based upon what I mentioned previously and what I just mentioned above, can you show me code and/or tell me what you would do to solve the memory problem I am having?
|
|
|
|
|
You have two processes. It isn't clear which one is running out of memory but because they are different processes they are different and neither would impact the other UNLESS there is something odd with the environment setup.
If there is something odd in the environment they you should at least track that down and understand it first. It would have to do with a system and\or user limit on the maximum memory possible. You can't figure out the environment problem by looking at the code you have.
Otherwise if the following are all true
- App1, the one that uses Process, is single threaded (not just assumed but actually is.)
- App1 is the one running out of memory
Then something in App1 before you make the Process call is using a lot of memory.
If it is App2 then either App2, not App1, has a bug or one of the options you are passing is wrong.
|
|
|
|
|
I have the following addtional questions to ask you since I am the only programmer at my small company, I have have 1 year of experience, and I have never come across memory issues in the past"
1. Based upon your statement, "It isn't clear which one is running out of memory but because they are different processes they are different and neither would impact the other UNLESS there is something odd with the environment setup.". Can you tell me what would be an 'odd' setup in my environment?
2.If there is something 'odd' setup in the environment, can you tell me how to tell what is the system and/or user limit on the maximum memory possible? Is there a tool that I can use, a process that I can look at? Is there a reference I can use to know how to set set the maximum limits?
3. If app1 is using alot of memory before it makes the call, can you tell me how to check on the memory that app1 is using?
|
|
|
|
|
dcof wrote: Can you tell me what would be an 'odd' setup in my environment?
Someone messed up the virtual memory setup (they would need to do this explicitly) or it is being run in a situation, such as a hosted environment, that explicitly limits the memory.
dcof wrote: If app1 is using alot of memory before it makes the call, can you tell me how to check on the memory that app1 is using?
Pretty sure there is a C# api that tells you that. Google for it.
|
|
|
|