Home > Back-end >  TIdTCPServer writes a software, use after a period of time will appear "Out of memory"
TIdTCPServer writes a software, use after a period of time will appear "Out of memory"

Time:10-13

But seen in task manager memory footprint is more than 24 m.

I also changed the new and delete matching problem, and considering the TCP client may exit among any position, also bring new and delete in this format to write.

Try
{
The new...
}
__finally
{
The delete...
}

In addition, after the "Out of memory" message, sure, program will continue to run, until after several times, several days after the crash.

There are two TIdTCPServer, a common have 130 or so links, another is about 5.

CodePudding user response:

Upgrade to the latest version of the indy

CodePudding user response:

I think this is only a memory leak of the reason, in addition to the new delete and there is no other memory processing

CodePudding user response:

reference 1st floor wewaa response:
upgrade to the latest version of the indy.


Now have CB2010 indy10

CodePudding user response:

refer to the second floor ksrsoft response:
I think this is only a memory leak of the reason, in addition to have no other new delete memory processing


General tips "Out of memory", what is Out of memory, because the task manager to see memory only use for more than 24 m.

The other...

Functions provides called:
Delete (21 times)
The fflush (6 times)
Fwrite (6 times)
45 times fclose ()
Fread (2713 times)
45 times fopen ()
The stat (40 times)
The delete [] (84350 times)
New [] (84350 times)
Memset (1083 times)
SysReallocMem (669540 times)
SysFreeMem (6104307 times)
SysGetMem (6104323 times)
Strdup (4 times)
Free (112 times)
_lsetlocale (6 times)
New (30 times)
Calloc (10 times)
Strlen (68 times)
Realloc (1 times)
The malloc (97 times)
Memcpy (75322 times)
The Resource types, informs:
Object array (84350 allocs, 3 Max)
The object (30 allocs, 30 Max)
The memory block (6104426 allocs, 5737 Max)
The file stream (45 allocs, 2 Max)
The file handle (45 allocs, 2 Max)
Modules, informs:
00400000 11/18/2013 14:58:04 D: \ hyj \ server \ server exe
==========================================

CodePudding user response:

Connection is too much, or in even repeatedly, the SOCKET didn't really release

CodePudding user response:

reference 5 floor zz99 reply:
connection too much, or in the repeatedly, the SOCKET didn't really release


Connection now has more than 100, was often disconnect again, should be released, I have the time to see

Idtcpsrvr1 - & gt; Contexts - & gt; The LockList () - & gt; Display the Count the number of connections is to host a so much.

CodePudding user response:

For professional tools to do professional thing, let not professional director don't; Let go of those functions, let FastMM come,

CodePudding user response:

The
reference 7 floor Uindex response:
for professional tools to do professional thing, let not professional director don't; Let go of those functions, let FastMM come,


How to use cb2010 FastMM, program will dynamically loading the DLL, the DLL program also want to change?

CodePudding user response:

TIdTCPServer OnExecute event is executed in the thread
Therefore never carried out within the OnExecute events related to redraw the control interface operation
Reason: the cause message blocking.

For example:

OnExecute () event
{
NetwowkSpeed - & gt; Caption=IntToStr (Value);//NetwowkSpeed TLabel
}


To:

Add a component TTimer * Timer1
Add a variable: int SpeedValue

OnExecute () event
{
SpeedValue=https://bbs.csdn.net/topics/Value;
}

To build a TTimer
Timer1Timet () event
{
NetwowkSpeed - & gt; Caption=IntToStr (SpeedValue);
}

So do not be "Out of memory"

CodePudding user response:

If it is:
Try
{
The new...
}
__finally
{
The delete...
}

Has nothing to do with new and delete matching problem!

CodePudding user response:

references 9 f sczyq response:
TIdTCPServer OnExecute event is executed in the thread
Therefore never carried out within the OnExecute events related to redraw the control interface operation
Reason: the cause message blocking.

For example:

OnExecute () event
{
NetwowkSpeed - & gt; Caption=IntToStr (Value);//NetwowkSpeed TLabel
}


To:

Add a component TTimer * Timer1
Add a variable: int SpeedValue

OnExecute () event
{
SpeedValue=https://bbs.csdn.net/topics/Value;
}

To build a TTimer
Timer1Timet () event
{
NetwowkSpeed - & gt; Caption=IntToStr (SpeedValue);
}

So do not appear "Out of memory"


Yes, I now thread is not about the interface and the database related operations, are each thread has a corresponding structure in staging, and then the main thread of a timer timing to deal with.

Another behind that
 try 
{
The new...
}
__finally
{
The delete...
}


Is it possible for new returns null, and then back to perform the delete and there is an error?

CodePudding user response:

Basically not possible, either to:

Obj=new...

If (obj)
Try
{
.
}
__finally
{
The delete obj.
}

CodePudding user response:

General pointer errors is AV

CodePudding user response:

The
refer to 12 floor sczyq reply:
basically not possible, either to:

Obj=new...

If (obj)
Try
{
.
}
__finally
{
The delete obj.
}



Like the nested is also no problem!

Try
{
The new...
Try
{
The new...
}
__finally
{
The delete...
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related