public function collectGarbage()
    {

        // the probability that we want to collect the garbage (float <= 1.0)
        $garbageCollectionProbability = $this->getSessionSettings()->getGarbageCollectionProbability();

        // calculate if the want to collect the garbage now
        $decimals = strlen(strrchr($garbageCollectionProbability, '.')) - 1;
        $factor = ($decimals > - 1) ? $decimals * 10 : 1;

        // if we can to collect the garbage, start collecting now
        if (rand(0, 100 * $factor) <= ($garbageCollectionProbability * $factor)) {
            // load the session manager instance
            /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $sessionManager */
            $sessionManager = $this->getApplication()->search(SessionManagerInterface::IDENTIFIER);
            // load the system logger instance
            $systemLogger = $this->getSystemLogger();
            // iterate over all session managers and remove the expired sessions
            foreach ($sessionManager->getSessionHandlers() as $sessionHandlerName => $sessionHandler) {
                try {
                    if ($systemLogger && ($sessionRemovalCount = $sessionHandler->collectGarbage()) > 0) {
                        $systemLogger->debug(
                            sprintf(
                                'Successfully removed %d session(s) by session handler \'%s\'',
                                $sessionRemovalCount,
                                $sessionHandlerName
                            )
                        );
                    }

                } catch (\Exception $e) {
                    if ($systemLogger) {
                        $systemLogger->error($e->__toString());
                    }
                }
            }
        }
    }