DEV Community

Seungwoo Khang
Seungwoo Khang

Posted on

I'm curious about how to use Xcode Instruments for a React Native iOS app. Could you provide some guidance?

I am experiencing issues while profiling an iOS app developed with React Native.

I attempted to verify if the memory leak examples purportedly related to React Native would be detected by the Xcode Instruments Leaks template. However, in all cases, no memory leaks were detected.

Is there anyone who can provide a practical example of a memory leak in React Native that can be detected using the Xcode Instruments Leaks template?

Or is there an additional step required to apply the Instruments tool to React Native code?

Currently, I am using React Native 0.74.2 and Xcode 15.2, and my test involved simply running Instruments in Xcode, opening the app with the Leaks template, and conducting the test.

Here is the example code:

const MemoryLeakExample = () => {
useEffect(() => {
const intervalId = setInterval(() => {
console.log('interval is running');
}, 1000);
return () => {
console.log('leak');
};
}, []);
return (

MemoryLeak Example

);
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)