title: Impact of sticky service in an application with huge monolith code base in Android?
body: <p>As we all know,<a href="http://javavikings.blogspot.com/2011/03/3-memory-segmentscodeheapstack.html" rel="nofollow noreferrer">Java memory model</a> consists of data (or code), stack and heap segments. I presume that the same is the case with Android. I have a single monolith application (let's consider the code base of this application to be too huge). When I start the application the activities and fragments within the application gets loaded into Dalvik JVM and offloaded. When this is the case, how this works with Service? Let's say I have a <code>STICKY_SERVICE</code> like,</p>
  
  <pre><code>public class CountingNumberService extends Service {
      @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
          for(int i=0; i&lt;100; i++) {
              //Do something
          }
          return Service.START_STICKY;
      }
      @Override
      public IBinder onBind(Intent intent) {
          /**
           * This has to do with some inter process communication
           */
          return null;
      }
  }
  </code></pre>
  
  <p>Since the service is <code>STICKY</code> it makes the process behave like a persistent process and it is always running. Now consider I stopped using my application and as a user I believed that application is closed (I'm closing it or clearing it from recents) but since my service is <code>STICKY</code> it would always be running and I assume I would have the following impact,</p>
  
  <ol>
  <li>I would eat user's battery.</li>
  <li>Some additional code (other than service) will be running along with the application (?)  not sure though. If it's the entire application sitting within data segment then it will not allow other application to run smoothly.</li>
  </ol>
  
  <p>I'm kinda confused on <code>STICKY</code> service on a process (a huge monolith code) and it's impact. Can someone clarify me on this please?</p>