I would like to understand if I should clear the prototype beans from memory manually myself.
In the Spring documentation, you can see: "Client code needs to clean up objects with a prototype and release expensive resources that the bean (s) prototype supports.
So, from this, it seems to you that you should clean the beans prototype yourself.
However
I am using VisualVM memory profiler . I created some prototypes - beans. You can see 51 of them.

Then you can see the situation when the garbage collector clears the memory - the entire beans prototype is cleared .

So can anyone clarify the situation? The prototype-beans is successfully removed by the garbage collector, or should we clean them manually (if so, how)?
Addition. Some guys asked to show the prototype code - beans. In fact, I do not see any point in this, because in a specific example I create them only as a test, and this does not apply to the real situation with cleaning the beans prototype from memory. Developers can create beans prototypes in different ways, but their behavior in the future does not depend or does not depend on the method of creation.
, 400 , Prototype- beans, . , beans VisualVM, , beans .
, , , bean.
beans :
for(int i=0;i<10;i++){
Prototype1 prototype1=applicationContext.getBean(Prototype1.class);
Prototype2 prototype2=applicationContext.getBean(Prototype2.class);
prototype1.test1();
prototype2.test2();
}
bean:
@Service
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class Prototype1 {
private int number;
public Prototype1() {
System.out.println("Prototype1 was created.");
}
public void test1(){
}
}