A comprehensive, web-based Operating System (OS) project that detects memory leaks in user-provided code (initially focused on C/C++), provides detailed analysis, and suggests direct solutions to fix them. This project is developed by a 4-member B.Tech team for 5th semester OS principles course.
MLDA (Memory Leak Detector & Code Analyzer) is a universal memory leak detection tool that helps developers identify and fix memory management issues in their C/C++ code. The application provides real-time analysis, visualizations, and actionable recommendations to improve code quality and prevent memory leaks.
- Large, user-friendly code input area
- Syntax highlighting support
- Sample code loading functionality
- Clear editor option
- Total Allocations: Count of all malloc/calloc/realloc calls
- Total Frees: Count of all free() calls
- Memory Leaks: Number of detected memory leaks
- Leaked Bytes: Total amount of memory leaked
- Critical Issues: Count of critical code quality issues
- Interactive pie chart showing:
- Allocated memory
- Freed memory
- Leaked memory
- Comprehensive list of all detected memory leaks
- For each leak, displays:
- Variable Name: The variable that caused the leak
- Line Number: Exact location in code
- Function: Type of allocation function used
- Estimated Size: Memory size in bytes
- Fix/Solution: Actionable solution to fix the leak
- Memory Allocation Analysis: Detailed breakdown of allocation and deallocation calls
- Memory Balance Status: Shows if memory is balanced or unbalanced
- Code Quality Warnings:
- Missing NULL pointer checks after allocation
- Unsafe function usage (e.g., strcpy without bounds checking)
- Other potential security issues
- Line graph visualization showing:
- Memory usage over code execution
- Memory allocation and deallocation patterns
- Helps identify where memory leaks occur during execution
- Best practices for preventing memory leaks:
- Always free allocated memory
- Check for NULL pointers
- Use safe string functions
- Implement proper error handling
- Use memory debugging tools
- Follow RAII principles
- Regular code reviews
- A modern web browser (Chrome, Firefox, Safari, Edge)
- No additional installation required!
- Clone the repository:
git clone https://github.com/AdityaPandey-DEV/Memory-Leak-Detector.git
cd Memory-Leak-Detector- Open the HTML file in your browser:
open index.htmlOr simply double-click the index.html file.
Alternatively, visit the live site: https://adityapandey-dev.github.io/Memory-Leak-Detector/
- Load Sample Code: Click the "Load Sample" button to load example code with memory leaks
- Enter Your Code: Paste or type your C/C++ code in the editor
- Analyze: Click "Analyze Memory" to run the analysis
- Review Results:
- Check the dashboard for quick statistics
- Explore the tabs for detailed analysis
- Review recommendations for best practices
- Fix Issues: Use the suggested fixes to resolve memory leaks
- HTML5: Structure and layout
- Tailwind CSS: Modern, responsive design
- JavaScript: Analysis engine and interactivity
- Chart.js: Data visualization (pie charts and line graphs)
- Static Code Analysis: Parses C/C++ code to detect:
- Memory allocation calls (malloc, calloc, realloc)
- Memory deallocation calls (free)
- Memory leak patterns
- Unsafe coding practices
- Tailwind CSS CDN: For styling
- Chart.js: For visualizations
- Prism.js: For syntax highlighting (optional)
This project demonstrates several key Operating System concepts:
-
Memory Management:
- Heap allocation and deallocation
- Memory leak detection
- Memory tracking and monitoring
-
Process Memory Layout:
- Understanding stack vs heap
- Dynamic memory allocation
- Memory lifecycle management
-
Resource Management:
- Proper resource cleanup
- Memory leak prevention
- Resource tracking
-
System Calls:
- Understanding malloc/free system calls
- Memory allocation strategies
- Error handling in memory operations
Memory-Leak-Detector/
β
βββ index.html # Main application file (single-file HTML)
βββ README.md # Project documentation
βββ .git/ # Git repository
This project serves as a practical implementation of:
- Memory Management Theory: Understanding how memory allocation works
- Static Analysis: Code analysis without execution
- Web Development: Modern web technologies
- Data Visualization: Presenting complex data in understandable formats
- Problem Solving: Identifying and fixing memory-related issues
Potential improvements for future versions:
- User authentication and history (Firebase integration)
- Support for more programming languages
- Real-time code execution analysis
- Integration with Valgrind or similar tools
- Export analysis reports (PDF/JSON)
- Code editor with syntax highlighting
- Multiple file analysis
- Performance metrics
Developed by a 4-member B.Tech team for 5th semester Operating Systems course.
This project is licensed under the MIT License with Attribution - see the LICENSE file for details.
Important: When using, modifying, or distributing this software, please provide appropriate credit to:
- Aditya Pandey (AdityaPandey-DEV) - Original Creator
- MLDA Team - Development Team
- Link to original repository: https://github.com/AdityaPandey-DEV/Memory-Leak-Detector
This project is developed for educational purposes as part of the B.Tech curriculum.
This is an academic project. For suggestions or improvements, please open an issue or submit a pull request.
For questions or feedback, please contact the development team.
Note: This is a static analysis tool that simulates memory leak detection. For production code, always use professional tools like Valgrind, AddressSanitizer, or Dr. Memory for comprehensive memory debugging.