Choipadua17 the exact amount needed will depend on the number of dependencies Composer has to deal with. Currently Bazaar tries to set 1GB of memory https://github.com/extiverse/bazaar/wiki/PHP-memory-limit
Part of this memory could be SWAP instead of actual RAM, but in shared hosting this will usually not be an option I guess.
The real memory-efficient solution is currently not compatible with Bazaar. It would be to use the composer client on a more powerful local setup , install or update Flarum as needed locally, then upload the lock file to the server and install the dependencies from the lock file. That way Composer doesn't need to perform the dependency checks on the server. Hopefully remote lock file generation will be added to Bazaar in the future but we're not there yet.