npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

memory-leak-mointor

v1.0.4

Published

Find memory leaks for react-native components

Readme

React Native Memory Leak Monitor 🔍

🔥 A powerful memory leak detection tool for React Native, inspired by LeakCanary! Monitor and catch memory leaks in real-time.

⚠️ Currently Android Only (iOS coming soon! 🍎)

✨ Features

🔄 Real-time memory usage monitoring
🎯 Component-level leak detection
⏱️ Session-based memory analysis
📊 Zustand store integration
📱 Memory metrics tracking
🚨 Automatic leak notifications
🎁 Easy-to-use HOC wrapper

🚀 Installation

npm install memory-leak-monitor
# or
yarn add memory-leak-monitor

🤖 Android Setup

Add to android/app/build.gradle:

dependencies {
    // ... other dependencies
    implementation project(':memory-leak-monitor')
}

📖 Basic Usage

1. 🌍 Wrap Your App

import { MonitorMemory } from "memory-leak-monitor";

function App() {
  return (
    <MonitorMemory
      interval={1000} // Update interval in ms
      sessionDurationMinutes={0.5} // Session duration
    >
      {/* Your app content */}
    </MonitorMemory>
  );
}

2. 🎯 Monitor Components

import { withLeakDetection } from "memory-leak-monitor";

const MyComponent = () => {
  // Your component code
};

export default withLeakDetection(MyComponent, "MyComponent");

3. 📊 Track Memory Stats

import { useLeakDetectionStore } from "memory-leak-monitor";

function MemoryDisplay() {
  const memoryInfo = useLeakDetectionStore((state) => state.memoryInfo);

  return (
    <View>
      <Text>Used Memory: {memoryInfo?.usedMemory} MB</Text>
      <Text>Available: {memoryInfo?.availableMemory} MB</Text>
    </View>
  );
}

🛠️ API Reference

🌟 MonitorMemory Component

<MonitorMemory
  interval?: number;          // Memory check interval (ms)
  sessionDurationMinutes?: number;  // Monitoring session duration
>

🎨 withLeakDetection HOC

withLeakDetection(
  WrappedComponent: React.ComponentType,
  componentName: string
)

🪝 useLeakDetectionStore Hook

const {
  memoryInfo, // Current memory metrics
  leaks, // Detected memory leaks
  startTracking, // Start tracking a component
  stopTracking, // Stop tracking a component
  subscribeToMemoryUpdates, // Subscribe to memory updates
} = useLeakDetectionStore();

📋 Memory Info Type

type MemoryInfo = {
  totalMemory: number; // Total device memory (MB)
  availableMemory: number; // Available memory (MB)
  usedMemory: number; // Used memory (MB)
  appMemory: number; // App's memory usage (MB)
  isLowMemory: boolean; // Low memory warning
  lowMemoryThreshold: number; // Low memory threshold (MB)
};

🎯 Detection Settings

Default thresholds for leak detection:

📊 Minimum memory change: 5MB
📈 Significant increase: 20MB
🔄 Sustained increase window: 8 readings
💾 System memory threshold: 50MB

💡 Best Practices

  1. 🏁 Start monitoring early in app lifecycle
  2. 🎯 Monitor suspicious components first
  3. ⏱️ Use sessions during development
  4. 📝 Check memory after major UI changes
  5. 🔄 Monitor component mount/unmount cycles

⚠️ Limitations

  • 🤖 Android only (iOS coming soon!)
  • 📱 Readings vary between devices
  • 🔄 Background processes affect metrics
  • 🗑️ Garbage collection impacts results

🤝 Contributing

We love contributions! Check out our Contributing Guide for guidelines.

📄 License

MIT

💪 Support

Found a bug? Have a feature request? Open an issue!

🌟 Show Your Support

Give a ⭐️ if this project helped you!