Do you lose the memory location forever like on a normal computer?
Or does the Arduino simply forget you allocated anything?
I don't care at all if the data is gone forever, I just want to know if the memory itself will be available again if the Arduino is shut down and restarted.
If the answer is that the memory locations are not lost then I have a further question.
Is there a library for creating an encapsulated memory block in the arduino? So that I never go over-memory or out of bounds and cause the program to crash. I can make one myself, but I just figured I'd ask.
Arduino Uno & similar have SRAM and Flash. Flash has your program (PC equivalent is hardest) but SRAM is just like PC RAM ... power off and information is gone.
I was always told it was very dangerous to allocate memory (using "new" in C++ or "malloc" in C) without freeing it since that causes memory leaks. I thought that those leaks persisted after the program finished running so I was worried that would also happen on the Arduino and the memory size might gradually reduce over time. Am I fundamentally misunderstanding memory leaks?
Yes absolutely.
Memory leaks are dangerous because as the program runs, free memory becomes less and less and at some point the program will freeze. But all this applies only to one session of work, after the restart, all memory is freed.
If you do dynamic memory allocation, directly or indirectly in an Arduino program, you may indeed experience leaks which will mean that your available heap shrinks. Eventually,(or indeed quite rapidly) this may cause unexpected behavior or a crash.
This is perfect. So allocating memory won't damage the permanent memory capabilities of my Arduino when power is lost. I just have to track memory usage. Thanks so much!