Combining Machine Learning and Lifetime-Based Resource Management for Memory Allocation and Beyond