'What are the memory management differences between Get.put(SomeClass(), permanent: true) and Get.put(SomeGetXService())

I am using Getx and its dependency injection mechanism.

sometime I am overthinking - should I inject a class that should remain in memory (for good as a Singelton) using

Get.put(SomeClass(), permanent: true)

or using

Get.put(SomeGetXService())

by reading the documentation, both ways seems to put the class in memory as Singelton, and it can only be deleted explicitly (i.e. not with Get.smartManagement).

as for me, I prefer not to extend the class with GetxService, since the first option is simpler to implement - but I feel like I might be missing something. having the class in memory as Singelton through out the app life-span is a must. Thanks for your help



Solution 1:[1]

Your argument type is wrong, instead of Authentication you should use SecurityContext. The javadoc for the @CurrentSecurityContext says:

Annotation that is used to resolve the org.springframework.security.core.context.SecurityContext as a method argument.

Otherwise, if you just want the Authentication you don't need any annotation to resolve it. If you want the Principal of the authentication, you can use the @AuthenticatedPrincipal annotation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcus Hert da Coregio