A
A
A2D22015-11-25 13:34:19
Arduino
A2D2, 2015-11-25 13:34:19

Arduino, can the memory fill up so that the sketch can't work?

1) For example, if you write a sketch that displays numbers from 1 to infinity, then how long can this operation continue?
2) Will any sketches run continuously?
3) Does the port monitor have something in common with memory? For example, if you display a set of numbers, then where are these numbers stored?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Max, 2015-11-25
@MaxDukov

1. the counter will overflow.
2. how to look at this question - you can check a condition in the main loop that will work only 1 time (or never) - but this condition will be checked continuously.
3. no. The port monitor shows you what has come from the controller to the port. What you see on the monitor is already stored on the computer.

A
Alexander Gusev, 2015-11-25
@Sanchogus

1) Unsigned long is used to store positive integers in the range 0 to 4,294,967,295 (2^32 - 1) and occupies 32 bits (4 bytes) in memory. This number will constantly occupy 4 bytes in the microcontroller, nothing will overflow to the max value.
2) Yes, unless you do otherwise in the program code. :)
3) The port monitor application running on your PC takes up the RAM of your PC.

V
Vitaly Filinkov, 2015-11-25
@vitfil

Well, to answer the question in the title, IT CAN! For example, stack overflow.

S
svd71, 2015-11-26
@svd71

Any work with the stack can lead to memory leaks, as a consequence of the failure of the executable code and, most often, the automatic start of the code from the beginning.
What can lead to stack overflow:
- passing a bunch of parameters through the stack when calling functions;
- incorrect use of interrupt or function calls: when a function or interrupt is called again before the end of execution while saving registers on the stack;
- inept distribution or a large number of variables;
- inept work with pointers.
Each item in itself is a separate topic for conversation. Therefore, I think it is not worth quoting excerpts from the release notes.
To detect such problems, you need some knowledge of assembler to understand how the compiler builds the executable code and how it will work with it. Is it possible to debug such things? Can. It is enough to use emulators. I only use two: atmel studio and ISIS. And they are enough for me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question