Hi,
Yes pooling will take memory. But this is not the layer itself or its definition that uses the memory, but the fact that it introduces more intermediary results (that are then required to compute the gradients).
If you replaced the pooling with  out = out + 1, you will get similar thing.
The pooling might help though as the output will be smaller and the intermediary results of the next layers will be smaller as well.