Button interrupts with Nano 33 BLE

Hello, I am trying to use two buttons to write values to a Bluetooth characteristic inside interrupts. The code runs perfect but after about 20 button presses the code just stops working, so I’m thinking it maybe runs out of memory? Any ideas on the issue would be greatly appreciated.

#include <ArduinoBLE.h>

const int ledPin = LED_BUILTIN;     // set ledPin to on-board LED
const int shiftUpButtonPin = 2;
const int shiftDownButtonPin = 3;  
volatile byte shiftUpState = 0;
volatile byte shiftDownState = 0;

BLEService ShifterService("597dbdfd-2db2-42e3-ad54-d2aef36e4805");
BLEBooleanCharacteristic shiftUpCharacteristic("11bb186f-748a-4542-ac48-032e589d5e48", BLENotify);
BLEBooleanCharacteristic shiftDownCharacteristic("0c618810-b694-426b-aed1-357c35978eec", BLENotify);

void shiftUp(){
  shiftUpState = !shiftUpState;
  shiftUpCharacteristic.writeValue(shiftUpState);
  digitalWrite(ledPin, shiftUpState);
}

void shiftDown(){
  shiftDownState = !shiftDownState;
  shiftDownCharacteristic.writeValue(shiftDownState);
  digitalWrite(ledPin, shiftDownState);
}

void setup() {
  Serial.begin(115200);
  //while (!Serial);

  pinMode(ledPin, OUTPUT);
  pinMode(shiftUpButtonPin, INPUT_PULLUP);
  pinMode(shiftDownButtonPin, INPUT_PULLUP);

  if (!BLE.begin())                 // initialize the BLE device
  {                                 // 1 on success, 0 on failure
    Serial.println("Failed to start BLE!");
    while (1);                      // only wait out is to kill execution
  }

  BLE.setLocalName("Shifter");
  BLE.setAdvertisedService(ShifterService);

  ShifterService.addCharacteristic(shiftUpCharacteristic);
  ShifterService.addCharacteristic(shiftDownCharacteristic);

  BLE.addService(ShifterService);
  
  shiftUpCharacteristic.setValue(0);
  shiftDownCharacteristic.setValue(0);

  BLE.advertise();                  // start advertising

  attachInterrupt(digitalPinToInterrupt(shiftUpButtonPin), shiftUp, CHANGE);
  attachInterrupt(digitalPinToInterrupt(shiftDownButtonPin), shiftDown, CHANGE);
  digitalWrite(ledPin, LOW);

  Serial.println("Bluetooth device active, waiting for connections...");
}

void loop() {

  BLEDevice central = BLE.central();

  if(central){
    while(central.connected()){
      
    }
  }  
}

Do you see the same failure of the code if you don’t use interrupts, but instead use button state change detection code?

Button state change detection runs perfectly fine, I’m just trying to keep the power usage down by using interupts and the button state change seems to miss some presses.

See this thread on measuring free memory with the mbed OS.
https://forum.arduino.cc/t/solved-measure-free-sram-of-nano-33-ble-sense-at-runtime/697716/3