I am well-aware that you created the topic. I have seen your question in Bosch forum as well. @mcmchris the IDEs can come with different compilers, lib versions etc. At the time you have done that the PlatformIO might be using a different stuff than Arduino IDE, so at that time, highly likely, PlatformIO was using libs occupying less RAM space, so by pure chance you get that working because you only needed just a bit more space. I wish you at least would provide what were the lib/os versions so the answer you tick would make a little sense at least.
Run the above script I provided in Arduino IDE or PlatformIO IDE, whereever you want, you will get an error with the current versions.
The solution offered by @jlutzwpi will work anytime if you just out of like 2KB RAM, so that is a useful one.
Another useful thing one can try to recompile the mbed-os. The link I provide has a guide on that. However if you need like at least 20KB space, that is also not enough.
One amazing solution would be using the RAM of BHI260AP which is 264KB which I am currently working on.