title: Why a global Map in Apex Schedulable class doesn't hold any values?
body: <p>I'm trying to use a global Map variable in the finish() method of a batchable class, but it behaves weirdly, I'm sure I'm doing something wrong, but don't know where. 
  In the simplified code below, the first debug message outputs the actual size of the map as expected. However, the debug message in the finish() method outputs 0, as the size of the same map. It looks like the map gets re-instantiated somewhere along the way, but I'm not sure where.</p>
  
  <pre><code> global class MySchedulableClass implements Database.Batchable&lt;sObject&gt; {
  
  
      global map&lt;string,string&gt; StringStringMap;
      global string query;
  
  
      global MySchedulableClass(){    
  
        if (query == null)
           query = 'Select id, name From Contact LIMIT 20';  
        if (StringStringMap == null){
              StringStringMap = new map&lt;string,string&gt;();
          }
       }
  
      global Database.QueryLocator start(Database.BatchableContext BC){
  
          return Database.getQueryLocator(query);
      }
  
      global void execute(Database.BatchableContext BC,List&lt;sObject&gt; scope){
          for(Sobject s: scope) {
              con = (Contact) s;          
              StringStringMap.put(s.id, s.name);                                                                  
          }
          system.debug('Map size:' + StringStringMap.size());
  
      }
  
      global void finish(Database.BatchableContext BC){       
            system.debug('Map size:' + StringStringMap.size());
      }
  }
  </code></pre>