Erratic behavior from Arduino

Hello, I have a problem with one of my projects. I used the freeRam() function and library to detect how much free RAM there is and it said about 1200KB. When I called delay() in one of my functions, it somehow jumped to a location in Setup, executed that, and went back to the beginning of the function the code was in the middle of executing. I have no idea why this happens and I've always expected the Arduino to be a regular computing device that should not have such a problem. Is it a bug?

The thing is, I've been thinking it's a memory error as it is known to cause random behavior, but this?

I want to experiment, so I am wondering whether there is an upgrade to ATMEGA328 that has 2.5KB or more memory.
What's the most I can put on my system?

How can we help you when we can't see your code ?? Post it using code tags !

davidl_i:
Hello, I have a problem with one of my projects. I used the freeRam() function and library to detect how much free RAM there is and it said about 1200KB.

I WANT one of those 1.2 MByte Arduinos!

As waski said, post your code. Assuming you meant 1200 bytes, rather than 1200 KB, your problem is likely in your code. Free RAM is only meaningful in a program that has no bugs, and in which you are not fragmenting the memory with things like String objects.

https://raw.githubusercontent.com/0xDA71D/DME-Project-Repository--Updated-daily/master/mainP/mainP.ino

Don't use it. It causes erratic behavior.
The IDE tells you how much memory and ram is used when you upload a sketch.

Then what should I do?

In memory, I am referring to RAM, not the flash the code uses. The code compiles with no warnings or errors, and runs perfectly for a few minutes to a few hours. Then, the code acts up.

davidl_i:
Then, the code acts up.

What code?

Post your code here. Don't expect us to go looking for it somewhere else. That takes too long.

...R