title: Should I remove unused services from the service container in Symfony 2?
body: <p>I don't know if this has some benefits: should unused services be removed from the service container?</p>
  
  <p>For example, in my bundle configuration I can disable the use of <code>lang</code> options provider:</p>
  
  <pre class="lang-none prettyprint-override"><code>my_bundle:
      providers:
          lang:
              enabled: false
  </code></pre>
  
  <p>When the <code>lang</code> provider is enabled, the <code>provider</code> tag should be added. This service is defined in <code>services.xml</code> file and loaded through the extension:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;service id="my_bundle.provider.lang" class="My\Provider\LangOptionsProvider"&gt;
  </code></pre>
  
  <p>So, it's a good idea to remove this definition and why?</p>
  
  <pre class="lang-php prettyprint-override"><code>public function load(array $configs, ContainerBuilder $container)
  {
      // ...
  
      $loader-&gt;load('services.xml'); // Loads "my_bundle.provider.lang"
  
      if($config['providers']['lang']['enabled']) {
          // lang provider is enabled, add the tag
          $container-&gt;getDefinition('my_bundle.provider.lang')-&gt;addTag('provider');
      }
      else { // Is this really needed?
          // Remove lang provider definition (or just the tag?!)
          $container-&gt;removeDefinition('my_bundle.provider.lang');
      }
  }
  </code></pre>