Getting Out of memory issue while creating builds

how can we distribute memory flexibly across builds as all build occupy same amount of memory.