GithubHelp home page GithubHelp logo

javascript-memory-leak-simulation's Introduction

Memory Leak Simulation for a JavaScript Web App"

This is a simple JavaScript web app to simulate a memory leak. This can be used to understand how memory leaks occur and how to detect and debug them.

image

The App:

HTML File (index.html):

  • Contains two buttons: one to start the memory leak and one to stop it.

JavaScript File (app.js):

  • memoryLeakArray: An array that will keep references to the created objects, preventing them from being garbage collected.
  • leakInterval: Holds the reference to the setInterval function to control the memory leak simulation.
  • startLeak button: Starts the memory leak by creating objects and storing them in the memoryLeakArray every second.
  • stopLeak button: Stops the memory leak by clearing the interval.

Steps to Run

  1. Create a repository on GitHub for the project and save index.html and app.js in it.
  2. Deploy the web app. I recommend using a static site in render.com.
  3. Open the site in a web browser.
  4. Open the browser's Developer Tools in Edge or Chrome>Performance (Ctrl+Shift+I).
  5. Click the "Start Memory Leak" button to start the memory leak simulation.
  6. Observe the memory consumption in the "Performance" or "Memory" tab in Developer Tools.
  7. Click the "Stop Memory Leak" button to stop the simulation.

Example in Chrome Developer Tools>>Performance:

image

This simple JavaScript web app demonstrates how continuously allocating memory without releasing it can cause a memory leak. In real applications, memory leaks can occur in various ways. This is one example so you can test it using developer tools.

If you dont want to deploy your own site and just want to try it out check the site here: JavaScript Memory Leak Simulation Web App.

javascript-memory-leak-simulation's People

Contributors

buchatech avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.