Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory leak, Spring for Android
    text
    copied!<p>I have a potential memory leak at my code and I'm trying to find a solution. I'm using the Spring for Android framework. And more specific the </p> <pre><code> RestTemplate.exchange(); </code></pre> <p>In order to make an on the fly binding. However, when i make a memory analysis I get the following:</p> <p>1.628 instances of "com.products.Product", loaded by "dalvik.system.PathClassLoader @ 0x43692b80" occupy 1.363.064 (22,20%) bytes. These instances are referenced from one instance of "java.lang.Object[]", loaded by "". The dominator tree is the following:</p> <blockquote> <p>class com.products.ProductList @ 0x436d7ea8 System Class| 1.628 | 8 | 130.240 | 8</p> <blockquote> <blockquote> <blockquote> <p>mFilteredProducts java.util.ArrayList @ 0x43a4eab0| 1.628 | 24 | 130.240 | 6.552</p> <blockquote> <blockquote> <blockquote> <p>array java.lang.Object[1628] @ 0x43bdc888| 1.628 | 6.528 | 130.240 | 6.528</p> <blockquote> <blockquote> <blockquote> <p>[274] com.products.Product @ 0x4398b038| 1 | 80 | 80 | 760</p> <p>[1175] com.products.Product @ 0x43b26868| 1 | 80 | 80 | 808</p> <p>........</p> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> <p>The above one is the dominator tree. However I was wondering if there is a safe way to activate the garbage collector. Is the </p> <pre><code> System.gc(); </code></pre> <p>Safe? However,is there a way to stop taking this memory leak? The class com.products.Product is just a simple POJO which will bind the JSON fields to the corresponding attributes. Generally the POJO that is used to bind the JSON is as following:</p> <pre><code>@JsonIgnoreProperties(ignoreUnknown = true) //must be there all times most likely public class MyPojo { @JsonProperty("Products") private ArrayList&lt;Product&gt; products; public ArrayList&lt;Product&gt; getProducts() { return products; } public void setProducts(ArrayList&lt;Product&gt; products) { this.products = products; } } </code></pre> <p>com.products.Product:</p> <pre><code>@JsonIgnoreProperties(ignoreUnknown = true) //must be there all times most likely public class Products { @JsonProperty private String prodnum; @JsonProperty private String brand; @JsonProperty private String name; //get/set } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload