0

I have a simple app with one button (just for testing) and the memory usage in the application is about 83 MB. Here is My Code. I am wondering that the app size is about 18MB and it's using a lot of memory. this is the same problem in a real app where the memory usage is about 190 MB and increases over time as I navigate in the app and after some time the app is going to stick on the android device have memory less or equal to 1GB and on iPhone 6 real device.

import React, { useCallback, useEffect } from 'react';
    import {Text, TouchableOpacity , View} from 'react-native'
    import SplashScreen from 'react-native-splash-screen';
    
    function Foo () {
        useEffect(() => {
            SplashScreen.hide()
        },\[\])
       
      
      const handleClick = useCallback(() =>  {
          console.log('Click happened');
        },\[\])
      
        
          return (
                <View style={{flex:1, width:'100%',justifyContent:"center", alignItems:"center", height:"100%"}}>
                    <TouchableOpacity 
                        style={{
                            backgroundColor:"gray",
                            borderRadius:10,
                            justifyContent:"center",
                            alignItems:"center", 
                            width:"80%", 
                            height:50
                        }} onPress={() => handleClick()}>
                            <Text style={{color:"#fff", fontWeight:"bold"}}>Click</Text>
                    </TouchableOpacity>
                </View>
          )
      
      }
    
      export default Foo;

Here is the screenshot of the android studio

Engr.Aftab Ufaq
  • 3,356
  • 3
  • 21
  • 47
  • Read about memory leak in js example; https://stackoverflow.com/questions/59780268/cleanup-memory-leaks-on-an-unmounted-component-in-react-hooks – ishaba Jul 31 '21 at 05:57
  • there is no memory leak. for the example in my question but still high memory usage and increasing with .1MB per button click. – Engr.Aftab Ufaq Jul 31 '21 at 06:03

0 Answers0