Where is my memory going

I have an Arduino connected to a raspberry pi zero W. The program on the Arduino controls a flow meter and works very well. I have the serial monitor open on the raspberry pi running 24/7, which records flow and total usage. It has been running constantly for three weeks without a hiccup. The raspberry pi is connected to Cayenne my devices. so I am able to monitor the Ram and Storage readings. Over the three week period the Ram usage has increased from 30% to to 60% And the storage has increased from 3.2GB to 5.2GB. Is the Raspberry pi logging the serial monitor and storing it. and if it is where is it storing it. If this is the case how do i program the Arduino not to do it. There are no other programs running on the raspberry pi.

This seems to be more of a Pi question than Arduino. Maybe a Pi f0rum would be the place to ask.

Is the Raspberry pi logging the serial monitor and storing it. and if it is where is it storing it.

Even the Pi forum members will need to see your code to answer that.

If this is the case how do i program the Arduino not to do it.

Same deal. We have no idea what the mystery Arduino is doing so how can we tell you how to stop it.

The Arduino sketch:

const byte statusLed = 13;
const byte sensorPin = 2;

// The hall-effect flow sensor outputs approximately 4.5 pulses per second per litre/minute of flow.
const float calibrationFactor = 2.9;
volatile uint16_t pulseCount;

float flowRate;
float flowLitres;
float totalLitres;

unsigned long oldTime;
const unsigned long sampleDuration = 1000ul;

// ISR
void pulseCounterISR()
{
  pulseCount++;  // Increment the pulse counter
}


void setup() 
  // put your setup code here, to run once:
{
  // Initialize a serial connection for reporting values to the host
  Serial.begin(115200);

  // Set up the status LED line as an output
  pinMode(statusLed, OUTPUT);
  digitalWrite(statusLed, HIGH);  // We have an active-low LED attached

  pinMode(sensorPin, INPUT_PULLUP);

  pulseCount = 0;
  flowRate = 0;
  flowLitres = 0;
  totalLitres = 0;
  oldTime = millis();

  // The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
  // Configured to trigger on a FALLING state change (transition from HIGH
  // state to LOW state)
  attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounterISR, FALLING);


}

void loop() 
  // put your main code here, to run repeatedly:
{
  unsigned long chrono = millis();

  if ((chrono - oldTime) >= sampleDuration)   // Only process counters once per sampleDuration
  {
    // Disconnect the interrupt ISR while calculating flow rate and sending the value to the host
    detachInterrupt(digitalPinToInterrupt(sensorPin));

    // if we have calibrationFactor pulses then we have 1 l/minute
    flowRate = (pulseCount / calibrationFactor) ; // this is in l/min

    // Because this loop may not complete in exactly sampleDuration intervals we calculate
    // the number of milliseconds that have passed since the last execution and use
    // that to scale the output.
    flowRate *= (((float) sampleDuration) / (chrono - oldTime)) ; // this is in l/min

    // Divide the flow rate in litres/minute by 60 to determine how many litres have
    // passed through the sensor in 1s and multiply by number of second of sampling
    flowLitres = (flowRate / 60.0) * (sampleDuration / 1000.0);

    // Add the litres we measured to the cumulative total
    totalLitres += flowLitres;

   

    // Print the flow rate for this second in litres / minute
    Serial.print(F("\tFlow: ")); Serial.print(flowRate, 1); Serial.print(F("L/min"));

 

    // Print the cumulative total of litres flowed since starting
    Serial.print("\tTotal: "); Serial.print(totalLitres, 1); Serial.println("L");

    pulseCount = 0; // Reset the pulse counter so we can start incrementing again
    oldTime = millis(); // Note the time this processing pass was executed.

    // Enable the interrupt ISR again now that we've finished sending output
    attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounterISR, FALLING);
  
}
}

Sorry, should have posted the code. I posted it here because it appears the Arduino is saving to the Pi as there is nothing else running on the Pi

Don't worry about RAM, that's business as usual on Linux - see here for example: https://www.linuxatemyram.com.

As to consuming SD capacity, it sounds like you've something logging. Take a look at datestamps and file sizes in in /var/log.

But as already stated, this isn't the best place to get Pi advice.

You cannot guarantee that a serial interface is error free, so the receiver program on the Pi should be setup to detect any errors.

The Pi should not suffer memory leaks as a result of errors or miss-configurations in the data it is receiving.

I cannot see how looking at the Arduino side of the code would be any help as the what was going wrong on the Pi.