2024-07-01 02:47 AM
STM32F107RCT6 has 64K Bytes SRAM in total , i use just 26K Bytes, and heap still available, but it overflows, i get confused. if i just change Heap_4 to Heap_5, my code can compile successfully, but it doesn't work. how to solve this problem?
2024-07-01 02:57 AM
If the Linker reports an overflow something is clearly consuming it, so dig deeper as to what.
If using Heap and failing, make sure you check return pointer from malloc() and provide some diagnostic or telemetry to understand flow and dynamics in use.
Large arrays and local/auto variable allocation can lead to failure.
Inspect critically and debug...
2024-07-01 03:30 AM
i have checked my code, the largest array is 512 Bytes that was being malloced in the TcpServer thread, and i had changed this array smaller, it still overflow 416 Bytes. So i think this is not the true reason. i set the Linker Settings for the Minimum Heap Size and Stack Size is all 0x400 or even the 0x800, it will overflow more Bytes. if i set the Heap and Stack Size in default size(0x200), compile ok, but unworkable.
2024-07-01 03:46 AM - edited 2024-07-01 03:47 AM
@Hamster wrote:my code can compile successfully, but it doesn't work.
Compiling successfully merely shows that there are no errors of C syntax or semantics - it gives absolutely no indication that your code will actually do what you wanted!
@Hamster wrote:i have checked my code, the largest array is 512 Bytes that was being malloced in the TcpServer thread
If you're allocating it with malloc, then make sure that it gets released when you're finished with it!
Otherwise you will have a so-called memory leak - which is a great way to overflow your RAM!
https://en.wikipedia.org/wiki/Memory_leak