Relating RAM usage with stack allocation and random resets in a microcontroller
(too long for a comment)

I think you ahev a memory problem, but it can either be using too much, or re-using something that should not be re-used in that way.

You say the RAM usage is 11%, but that can refer only to what is statically allocated, maybe including stack allocation, but it doesn't include dymanic memory (do you use malloc?) nor the actual stack use.

As a first step, determine the memory layout (DSEG, stack, heap) in both situations (with and without debugger). You might experiment with different layouts, to see how they influenece the problem.

If you use dynamic memory (heap, malloc() calls)you must get a grip on your heap use. How much memory is allocated to the heap, waht is your (peak) use?

Idem for stack use. What is your peak stack use?

Another approach is to remove parts of your application, intill you have identified the smallest code that shows the problem, and the line that, when removed, removes the problem. Very tedious, but sometimes the only option. Note that that one line might still not be the actual problem, but it sure gives you more info.