wavsse wrote on Wednesday, September 05, 2018:
I’m relatively new to the +TCP stack and while I’m having good success, I would welcome any advice or information regarding how +TCP manages heap allocation and release. I have both ipconfigZERO_COPY_TX_DRIVER and ipconfigZERO_COPY_RX_DRIVER set to 1, and I’m using BufferAllocation_1 and, of course, heap4.
At present, the +TCP stack seems to be working well on the surface as I’m able to send and receive UDP packets, and I’ve also implemented and tested a simple HTTP server … thus TCP is working as well.
For diagnostic purposes, I have a console readout that lets me inspect the heap using xPortGetFreeHeapSize() and xPortGetMinimumEverFreeHeapSize().
At startup, my heap consumption is around 29K ( I have several dynamically intantiated tasks that remain intact ) and all runs well. When I retrieve a simple web page using a browser, however, the heap consumption rises to ~45K (expected) … but then never goes back down again. After the HTTP transactions, I’m properly closing all involved sockets. I can retrieve the web page a 2nd time and it doesn’t climb any higher than the ~45K, so there’s no memory leak.
The last time I had +TCP diagnostic messages enabled, I didn’t notice any unusual consumption (leaks) in the buffer descriptors. The count rises with activity, as expected, but remains stable.
**What I’d like to understand better is exactly how and what the ZERO_COPY mechanism does, and how it impacts the heap and what sort of heap behavior is expected. In general, I need help with a bit deeper dive into the inner workings of the +TCP memory management so I can use more than superficial “appearance” for verifying my code integrity. I don’t want to create code that may be configured wrong or unnecessarily impacts TCP performance. **
I realize I may need to provide more configuration details, so please ask. It wont be possible to provide all my code involved as there’s simply too much, but I can post relevant snippets if required.
Thanks for any advice or help.