Assuming "solve" is meant loosely: much like in C++, with RAII-style resource management. The Ada standard library has what are called _controlled types_ which come with three methods: Initialize, Adjust, and Finalize. The Finalize method, for example is automatically called when a value of a controlled type goes out of scope. It can do things like deallocate dynamically allocated memory.
That said, Ada also has features that make C-style dynamic allocation less common. Ada does not have pointers but access types, and these are scoped like anything else. That means references cannot leak, and it is safer to allocate things statically, or in memory pools.
That said, Ada also has features that make C-style dynamic allocation less common. Ada does not have pointers but access types, and these are scoped like anything else. That means references cannot leak, and it is safer to allocate things statically, or in memory pools.