Got error 'Cannot allocate memory'

$ free -h shows the available memory decreasing to almost ZERO and this is the error eventually I get:

RuntimeError: [enforce fail at CPUAllocator.cpp:64] . DefaultCPUAllocator: can't allocate memory: you tried to allocate 12976128000 bytes. Error code 12 (Cannot allocate memory

what’s a better approach to load images or read images without allocating RAM ?