Home > Software engineering >  IOCP memory footprint
IOCP memory footprint

Time:09-21

Recent projects with the completion port to implement the service TCP communications, searched the code on the net, has been found that memory when using submit size increase:
I had a client, after the connection has been a simple string, the service side only receive, also didn't do other processing, going up all the department found that memory is the IOCP model has a problem, is to eat memory ah, because see the routine code repeatedly, didn't find the memory leak, VS debug end also didn't tip the memory leak, wondering, is there any player under the guidance of, can leave a qq, I put the code in the past, to help me have a look,

CodePudding user response:

Pay close attention to the new malloc application of memory, the last ever released

CodePudding user response:

0 f yuchenliu reference response:
project recently with the completion port to implement the service TCP communications, searched the code on the net, has been found that memory when using submit size increase:
I had a client, after the connection has been a simple string, the service side only receive, also didn't do other processing, going up all the department found that memory is the IOCP model has a problem, is to eat memory ah, because see the routine code repeatedly, didn't find the memory leak, VS debug end also didn't tip the memory leak, wondering, is there any player under the guidance of, can leave a qq, I put the code in the past, to help me see,


Your memory without good management, useless memory without timely release, IOCP actually don't need to use how much memory,

CodePudding user response:

Memory leaks and iocp mechanism no associated
Although before he also doubted
All memory leaks turned out to be a reason

CodePudding user response:

IOCP deliver the send or recv request, the need to the OVERLAPPED structure, this structure is generally so generated:

LPOVERLAPPED_SOCKET_RECV lpPerIOData=https://bbs.csdn.net/topics/NULL;

LpPerIOData=https://bbs.csdn.net/topics/(LPOVERLAPPED_SOCKET_RECV) HeapAlloc (
GetProcessHeap (),
HEAP_ZERO_MEMORY,
Sizeof (OVERLAPPED_SOCKET_RECV));

Did you see this structure you release, complete the routine if an error occurs (DWORD dwError), such as the transmission of the data length is 0 (DWORD cbTransferred), also need to be released: HeapFree (GetProcessHeap (), 0, lpPerIOData);

CodePudding user response:

Is mainly the upstairs said, when receiving buffer, or do you have a global buffer, use that, every time see will memory growth,

CodePudding user response:

Thank you for your reply to me, the problem also in the solution, I am a reference before CSDN a blogger source piggyxp (https://blog.csdn.net/piggyxp/article/details/6922277), I finished adaptation, the measured when memory increased quickly, the final collapse of the whole software, and then I'll use his source code, is simple to use network assistant to establish a connection, a string, found that memory will increase, and one is 4 k, basically connected but not sending data will not only his code, I repeatedly watched when receiving IOCP all use sentences or single architecture itself IO structure in the application of memory, and there is no repeat application (because will establish a connection and keep), I even global searching the new place, finally still didn't find!
Don't know a few master provide convenient qq here, want to communicate in detail with you,

CodePudding user response:

We provide advice I try first!
  • Related