We've been diagnosing an apparent memory leak in a Spring Boot application. We were unable to find anything that stood out in our code, but using VisualVM's memory profiler, we found something odd. When a controller is being hit by a request, a new instance of that controller is created. As specified below, these controllers should be singletons. Furthermore, these superfluous instances are never garbage collected and keep piling up. These controllers aren't referenced anywhere in the code, and are only created by whatever Spring magic creates it in the first place.
So my question is: what can cause a Spring component like this to start behaving like this, and how would I potentially go about debugging it?
The following is the class' annotations.
@Slf4j
@Validated
@RestController
@RequestMapping("profile")
public class ProfileController {
...
}