title: Memory growth react native
body: <p>My app includes only one home screen, and it should run for a long period of time(In kiosk mode, for weeks).</p>
  
  <p>After a while, I have noticed that it is crashing due to memory growth(it became something like 500,000K).
  I started to investigate this bug, and created a simplified version of this app: one component that all it does is changing the UI every 500ms, and ran it over night.</p>
  
  <p>My component code:</p>
  
  <pre><code>import React, {useEffect, useState} from 'react';
  import {StyleSheet, View, Text} from 'react-native';
  
  
  let counter = 0;
  
  const Home = ({
  }) =&gt; {
    // State
    const [param1, setParam1] = useState(0);
    const [param2, setParam2] = useState(0);
    const [param3, setParam3] = useState(0);
    const [param4, setParam4] = useState(0);
    const [param5, setParam5] = useState(0);
    const [param6, setParam6] = useState(0);
  
    // Effects
    useEffect(() =&gt; {
      // &lt;- component did mount + unmount equivalent
      const interval = setInterval(() =&gt; {
        counter += 1;
        setParam1(counter)
        setParam2(counter)
        setParam3(counter)
        setParam4(counter)
        setParam5(counter)
        setParam6(counter)
      }, 500);
  
      return () =&gt; {
        clearInterval(interval)
      };
    }, []);
  
    const connectivitySummary = () =&gt; {
      return (
        &lt;View&gt;
          &lt;Text&gt;{param1}&lt;/Text&gt;
          &lt;Text&gt;{param2}&lt;/Text&gt;
          &lt;Text&gt;{param3}&lt;/Text&gt;
          &lt;Text&gt;{param4}&lt;/Text&gt;
          &lt;Text&gt;{param5}&lt;/Text&gt;
          &lt;Text&gt;{param6}&lt;/Text&gt;
        &lt;/View&gt;
      );
    };
  
    return (
      &lt;View style={{flex: 1}}&gt;
        &lt;View&gt;{connectivitySummary()}&lt;/View&gt;
      &lt;/View&gt;
    );
  };
  
  export default Home;
  </code></pre>
  
  <p>The result is:
  <a href="https://i.stack.imgur.com/jlvQR.png" rel="nofollow noreferrer">UI result</a></p>
  
  <p>When I started to run this app, memory usage was around <strong><em>46,000k</em></strong>.</p>
  
  <p>After a night running, memory usage is <strong><em>214,338K</em></strong>:</p>
  
  <p><a href="https://i.stack.imgur.com/NNUla.png" rel="nofollow noreferrer">My app name is Check</a></p>
  
  <p>Can someone please tell me what am I missing? why this huge memory growth happening?</p>
  
  <p>About setInterval: I know that setInterval can cause memory leaks, but the GC suppose to clear it(please check <a href="https://stackoverflow.com/questions/14034107/does-javascript-setinterval-method-cause-memory-leak">Does JavaScript setInterval() method cause memory leak?</a>)</p>
  
  <p>React Native version: 0.60.5</p>
  
  <p>Thank you for your help!!</p>