Do you keep the cnUser connection open for the lifetime of the app? It might be worth trying to periodically close and re-open it to see if that helps.

Or perhaps try trapping the "out of memory" error, then close & re-open cnUser, recreate the Cmd object and try re-executing to see if that helps.

That won't be a proper solution, but it's a workaround that might help while you track down the bug.