ColdFusion Memory Issue: sdk-ScheduledExecutor
A quick post in case anyone else ever runs in to this memory issue.
Our CF servers seemed to have a "memory leak", in that the memory being used (Windows) by the CF service would gradually grow until it was maxing out the entire server.
Long-story-short, we found (with the folks over at xByte cloud hosting) in a thread dump that we had tens of thousands of hung (waiting) threads with the name: sdk-ScheduledExecutor
Turns out, that thread is created by the AWS SDK for Java, which we are not using. Not surprisingly, though, ColdFusion does use a version of this SDK for their cloud services functionality. We use that extensively when interacting with S3. At first we thought there could be a bug in CF or in the SDK if it's spawning all these threads. But, when pouring over Adobe's docs we found the following little tidbit on this page:

Oh! The getCloudService() function must be in a shared scope? In true Adobe fashion, none of the examples they give on that page actually show this requirement in practice!
Anyway, our devs had missed that, entirely. All our functions that interacted with S3 were starting out by creating the service object with getCloudService().
Turns out, as far as we can tell, every time that function is called, CF fires up a 'sdk-ScheduledExecutor' thread. The thread does the work you give it, then sits in a waiting state for another job that, in our case, would never come. So, after a while, we'd accumulate 1000s!
Solution: make sure 'getCloudService()' is called in a shared scope and reuse that object!
Going forward...and maybe I've missed something.... it would be helpful to have a way to close, or kill, this serviceObject. As it stands, once you fire it up, it runs forever?
Cheers!
