title: how to prevent GC_CONCURRENT statements in Logcat
body: <p>I have a requirement that I need to check the no.of lines in the File 'A' and if File 'A' exceeds my limit then I need to copy its contents into other file 'B' and then clear the contents of file 'A'.</p>
  
  <p>The above task I have to execute all the times So , I constructed "Service" to do this task. (I want to run this in back ground).</p>
  
  <p>From the Service I am launching a thread to execute the above task.( I have other task in Service which should run in parallel along with the task).</p>
  
  <p>I am using AlarmManager to keep my "Service" alive.</p>
  
  <p>Bottom line is that above task will run all the time. So far I succeeded in what I want to achieve. </p>
  
  <p><strong>But I have observed in the LogCat output that It is generating huge statements related to GC.</strong></p>
  
  <p>Like:</p>
  
  <pre><code>D/dalvikvm( 2579): GC_CONCURRENT freed 483K, 62% free 2608K/6727K, external 1628K/2108K, paused 2ms+2ms
  D/dalvikvm( 2579): GC_CONCURRENT freed 469K, 62% free 2608K/6727K, external 1628K/2108K, paused 34ms+2ms
  D/dalvikvm( 2579): GC_CONCURRENT freed 466K, 62% free 2608K/6727K, external 1628K/2108K, paused 1ms+2ms
  D/dalvikvm( 2579): GC_CONCURRENT freed 472K, 62% free 2609K/6727K, external 1628K/2108K, paused 7ms+2ms
  D/dalvikvm( 2579): GC_CONCURRENT freed 473K, 62% free 2607K/6727K, external 1628K/2108K, paused 2ms+1ms
  D/dalvikvm( 2579): GC_CONCURRENT freed 473K, 62% free 2607K/6727K, external 1628K/2108K, paused 1ms+2ms
  D/dalvikvm(  263): GC_EXPLICIT freed 351K, 58% free 3118K/7303K, external 10278K/11844K, paused 42ms 
  </code></pre>
  
  <p>I suspect my application leaking some memory or it is consuming heavy memory.
  with respect to performance I want to avoid this .
  Below is the code snippet that I am running all the time in thread.</p>
  
  <pre><code>public void run()
  {
      while (true) {
          if (WifiLogCollector.stoopThread)
              return;
          LineNumberReader lineNumberReader = new LineNumberReader(new FileReader(textfile));
          lineNumberReader.skip(Long.MAX_VALUE);
  
          if ((lineNumberReader.getLineNumber())  &gt; 20000) {
  
              FileChannel source = null;
              FileChannel destination = null;
  
              try {
                  source = new FileInputStream("/mnt/sdcard/textfile.txt").getChannel();
                  destination = new FileOutputStream("/mnt/sdcard/textbackupfile.txt")
                                  .getChannel();
                  destination.transferFrom(source, 0, source.size());
              } finally {
                  if (source != null) {
                      source.close();
                      source = null;
                  }
                  if (destination != null) {
                      destination.close();
                      destination = null;
                  }
              }
  
              PrintWriter writer = new PrintWriter(/mnt/sdcard/textfile.txt);
              writer.print("");
              writer.close();
              writer = null;
  
          }
  
          lineNumberReader.close();
          lineNumberReader = null;
      }
  }
  </code></pre>
  
  <p>the above is the run() method of my thread.</p>
  
  <p>Please help me what should be the changes I need do in my design to avoid GC logs and make my app memory efficient.</p>