Implement new memory management strategy for terrain profile queries so the system uses less memory.