To me it's a bit unclear what the last clause ("to limit memory usage...") refers to: the last of the three ways?  Perhaps a period and a separate sentence starting "In the last case, ..." would be clearer.