Does spring smart enough to create and destroy the instances of beans depending on how frequently they use in order to save RAM during application work ? If yes, should we apply some special configuration configurations or this ( save RAM ) property using by default?
As answered by @Dina Bogdan memory management is done by JVM garbage collector and all Spring and application can do is remove any strong reference to a bean that they never needs.
For singleton beans the reference is never removed for the duration of the application context life. This is because Spring keeps track of them and even if your application removes string reference from them they still will be strongly referenced by Spring cache.
In contrast to Singleton beans, the prototype beans are not kept by Spring and will be garbage collected once the application removes strong reference from them.
For other scoped beans such as request or session they they will be garbage collected after end of request or session unless application will still keep reference to them.
Now for your question. If you really want to manage how beans are garbage collected you can create Spring proxy that will reference to its target bean via weak reference. This will allow garbage collector to collect that bean when memory is tight.