Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Composition and Leak Detection #971

Open
kasniRC opened this issue Sep 6, 2024 · 2 comments
Open

Memory Composition and Leak Detection #971

kasniRC opened this issue Sep 6, 2024 · 2 comments

Comments

@kasniRC
Copy link

kasniRC commented Sep 6, 2024

Problem Statement

Should be capable of periodically or continuously monitoring the memory usage of the web rendering process, providing insights into the memory allocation of various components and associating them with specific code segments. Specifically, the tool should offer the following functionalities:

  1. Memory Composition Detection:
  • Memory Allocation Monitoring: Detect the different components consuming memory (e.g., DOM, JavaScript objects, CSS styles, caches, etc.) and generate visual reports showing the memory usage ratio of each part.

  • Dynamic Memory Tracking: The tool should track memory usage over time, allowing developers to observe memory changes in response to specific user interactions or time intervals.

  1. Memory Leak Detection:
  • Persistent Object Detection: Automatically identify objects or resources that are not released properly and flag objects that retain memory unnecessarily.

  • Garbage Collection (GC) Analysis: Analyze objects that are not reclaimed by the garbage collector and provide detailed reasons or hints to help developers locate the root causes of memory leaks.

  1. Code Correlation Analysis:
  • Code Traceability: For memory-hungry or unreleased resources, trace back to the relevant code segments where the memory was allocated or manipulated. This helps developers pinpoint the logic leading to high memory usage.

  • Hotspot Identification: Provide an automated mechanism to generate reports on memory or performance hotspots, highlighting the most likely code modules responsible for excessive memory consumption.

  1. Diagnostics and Optimization Suggestions:
  • Problem Visualization: Generate detailed memory usage charts and reports that show the memory footprint of different components, objects, or operations.

  • Optimization Suggestions: Based on the memory analysis, provide actionable recommendations for improving garbage collection, managing object lifecycles, and optimizing memory-related code.

Solution Brainstorm

  • Can refer to the way devtools captures memory snapshots to capture memory information, but you need to consider the performance implications
@kasniRC kasniRC changed the title Memory Detection Memory Composition and Leak Detection Sep 6, 2024
@Lms24
Copy link
Member

Lms24 commented Sep 6, 2024

Hey @kasniRC thanks for the suggestion!

I agree this sounds interesting! Memory profiling and related ideas have been floating around but so far aren't really a thing in the various Sentry SDKs (and neither in the product). We have no concrete plans though for these features, so I'm gonna backlog the issue.

cc @timfish feel free to chime in with ideas or quick wins!

@timfish
Copy link
Collaborator

timfish commented Sep 6, 2024

With Electron we can debug/profile all the renderer/browser processes from the main app process. This means we can potentially get a lot more info that you can with the regular browser SDK.

My main concern would be the performance implications because whenever I've run these tools myself to track down leaks and performance issues, they have a huge impact.

You can already use Sentry's browser profiling integration in the Electron renderers which uses browser js "self profiling" which is more geared to be used in production: https://docs.sentry.io/platforms/javascript/profiling/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants