title: Java short lived objects & garbage collection
body: <p>I am evaluating the performance impact of creating small short lived objects frequently (say every second) on garbage collection and memory footprint, especially on Android java implementation. </p>
  
  <p>To elaborate further, we have an application which receives frequent update from the network in thread and it is passed to application in a small structure. In C, we create a local variable of type structure and pass it like</p>
  
  <pre><code>void passToApp(int a, int b, int c) {
  
     AppStruct p;
     p.a = a;
     p.b = b;
     p.c = c;
     appFunction(&amp;p);
  }
  </code></pre>
  
  <p>This is not a problem in C as p is in stack. However in java, every object need to be allocated and later to be freed by GC.  </p>
  
  <pre><code>void passToApp(int a, int b, int c) {
  
     AppStruct p = new AppStruct();
     p.a = a;
     p.b = b;
     p.c = c;
     appFunction(p);
  }
  </code></pre>
  
  <p>Please share your insight on the situation and any best practices in such circumstances. </p>