System out of memory exception
Hello
We have done a client server socket programming using Visual C# 2005 and SQL SERVER.
The program works fine. But if there are many clients accessing the socket we stumble on the error
"System out of memory exception"
I will give out the details of the server socket.
1. We recieve all the details from the client
2. These details are in recieved in bytes which we convert into a string array
3. These details if proper will be written to the log file(if input details are right) or error log file(if details are wrong)
4. Thereafter these details will be displayed in a listbox(Problem arises here)
4.a) . If the details already exist it will be ignored.
5. We have used another thread which will inspect if there is another details coming in from client socket and this is taken care of and written in the list box.
6. We have also used
Control.CheckForIllegalCrossThreadCalls = false;
7.Now when there are many clients accessing the server while one is accessing the data from the listbox the second also takes the same data from the list box and that results in the error
System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at System.Windows.Forms.ListBox.NativeAdd(Object item)
at System.Windows.Forms.ListBox.ObjectCollection.AddI nternal(Object item)
at System.Windows.Forms.ListBox.ObjectCollection.Add( Object item)
at StepIIServer.Server.RunClient2() in E:\stepII\Server.cs:line 346
Can anyone throw some light on this error.
I am running into these troubled waters for the past week.
In case of doubts I will try to clarify.
Regards
|