Did you try https://gdal.org/user/virtual_file_systems.html#vsimem-in-memory-files GDAL writing to and reading from virtual memory?