How does fastai does so efficient memory management?

So built my own neural network and data loader to classify the image into 62 categories(capital letters, small letters and numbers). I have 43400 train images and 1054 test images. My system stuck when I tried to train the dataset using resnet18 but when I use more complex network resnet34 for the same task, it trains flawlessly. Bot h models are used as pretrained models. How does fastai accomplish this ??