Particle Boron with MMA8451

I am using Boron to measure position and acceleration using MMA8451 sensor.
First Scenario: I just use the example program given in particle.It reads the value from the sensor and directly prints through Serial port. It works perfectly and I am able to get all the values somewhat accurate.

Second Scenario: I store the data in sensor buffer. I get the value from sensor every two seconds(put boron to sleep for 2 seconds). Store it in the array which I created in Boron. Once the size of the array filled reaches a threshold value like 900 or 1000. I print all the values at once through Serial port.
In this scenario, I am getting negative maxed out values periodically like below.
Can you please let me know what might be the reason??

It’s impossible to say without seeing your code.