Good day.

Here is my code: (I listen to the 25th port of the local machine):

class Program { static void Main(string[] args) { TcpListener SMTP_Listener = new TcpListener(IPAddress.Any, 25); SMTP_Listener.Start(); Console.WriteLine("Starting..."); while (true) { Socket clientSocket = SMTP_Listener.AcceptSocket(); if (clientSocket.Connected) { string _sessionId = clientSocket.GetHashCode().ToString(); Console.WriteLine("Connected: " + _sessionId); new Thread(() => { StartProcessing(clientSocket, _sessionId); Console.WriteLine(">> Client thread is finished: " + _sessionId); }).Start(); } } } static void StartProcessing(Socket clientSocket, string _sessionId) { //Π›ΠΈΠΌΠΈΡ‚ сообщСния int _maxMessageSize = 1000000000; //Ρ‚Π°ΠΉΠΌΠ°ΡƒΡ‚ аТидания ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ ΠΎΡ‚ ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° int _commandIdleTimeOut = 6000000; //врСмя ΠΆΠΈΠ·Π½ΠΈ сСссии int _sessionIdleTimeOut = 80000; int[] arr = new int[1000]; for (int i = 0; i < 1000; i++) { arr[i] = i; } clientSocket.Close(); Console.WriteLine(">> Socket closed for client " + _sessionId); } } 

Calling code from another application:

  for (int i = 0; i < 30; i++) { try { SmtpClient client = new SmtpClient("machine_name", 25); MailMessage m = new MailMessage("localm@bank.lan", "+380662367263@domen.lan"); m.Body = i.ToString() + " (1)"; client.Send(m); Console.WriteLine(">> " + i + " (1)"); } catch { Console.WriteLine(">> " + i + " (2)"); } } 

The question is in performance - when you start the application, it takes 7.156 MB of operative, but after 30 connections, the program starts to occupy 7.548 MB , but after 17 minutes the load has dropped to 7.308 MB and this already remains for.

As I understand it, if the application architecture is correct, then the load should return to the original level, i.e. 7.156 MB of RAM, but this does not happen.

Tell me, please, what could be the reason why the program memory is not released?

Reported as a duplicate by members of Grundy , aleksandr barakin , VenZell , Abyx , insolor 26 Mar '16 at 3:18 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • What is the measure of "operative"? - Grundy
  • In the task manager! - Leonard Bertone
  • 2
    You have already asked such a question, and as a duplicate it was noted: ru.stackoverflow.com/questions/503796/… - Grundy
  • 2
    Not the fact that the memory is not released. Check out better with a memory profiler. (For example, Ants.) - VladD

0