You can think of Heroku dynos as completely independent servers running a copy of all your code, with their own local, temporary file system. In reality they're virtual servers running on EC2, but the result is the same.
This means the memory of one server is definitely not accessible from another. You need to use a shared data store, like a database, that all your dynos connect to.