
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
ngx-performance-diagnostics
Advanced tools
Angular library for detecting performance issues, change detection cycles, and memory leaks
🔍 Real-time performance monitoring and diagnostics for Angular applications
Detect performance issues, excessive change detection cycles, and memory leaks in your Angular applications with zero configuration. Perfect for development and debugging!
npm install ngx-performance-diagnostics --save-dev
import { Component } from '@angular/core';
import {
CdMonitorPanelComponent,
MemoryLeakPanelComponent
} from 'ngx-performance-diagnostics';
@Component({
selector: 'app-root',
standalone: true,
imports: [
// ... your imports
CdMonitorPanelComponent, // CD Monitor (right panel)
MemoryLeakPanelComponent, // Memory Monitor (left panel)
],
template: `
<router-outlet></router-outlet>
<!-- Diagnostic panels (development only) -->
@if (!isProduction) {
<ngx-cd-monitor-panel></ngx-cd-monitor-panel>
<ngx-memory-leak-panel></ngx-memory-leak-panel>
}
`
})
export class AppComponent {
isProduction = false; // Set from environment
}
import { Component } from '@angular/core';
import { ChangeDetectionMonitorDirective } from 'ngx-performance-diagnostics';
@Component({
selector: 'app-my-component',
standalone: true,
imports: [ChangeDetectionMonitorDirective],
template: `
<div cdMonitor="MyComponent">
<!-- Your component content -->
<h1>{{ title }}</h1>
</div>
`
})
export class MyComponent {
title = 'Hello World';
}
# macOS
open -a "Google Chrome" --args --enable-precise-memory-info --expose-gc
# Windows
chrome.exe --enable-precise-memory-info --expose-gc
# Linux
google-chrome --enable-precise-memory-info --expose-gc
Monitor change detection cycles for any component:
<div cdMonitor="ComponentName" [cdMonitorThreshold]="50">
<!-- Component content -->
</div>
Inputs:
cdMonitor: string - Component name for identificationcdMonitorThreshold: number - Warning threshold in cycles/second (default: 100)What it tracks:
Programmatic access to CD statistics:
import { ChangeDetectionMonitorService } from 'ngx-performance-diagnostics';
export class MyComponent implements OnInit {
constructor(private cdMonitor: ChangeDetectionMonitorService) {}
ngOnInit() {
// Subscribe to statistics
this.cdMonitor.stats$.subscribe(summary => {
console.log('Active:', summary.activeComponents);
console.log('Problematic:', summary.problematicComponents);
});
// Get current stats
const stats = this.cdMonitor.getStats();
// Export to JSON
const json = this.cdMonitor.exportStats();
// Clear all stats
this.cdMonitor.clearStats();
}
}
Monitor memory usage and detect leaks:
import { MemoryLeakDetectorService } from 'ngx-performance-diagnostics';
export class MyComponent implements OnInit, OnDestroy {
constructor(private memoryMonitor: MemoryLeakDetectorService) {}
ngOnInit() {
// Start monitoring
this.memoryMonitor.startMonitoring();
// Get report
const report = this.memoryMonitor.getReport();
console.log('Is leaking:', report.isLeaking);
console.log('Trend:', report.trendPercentPerMinute, '% per minute');
// Export report
const json = this.memoryMonitor.exportReport();
// Force garbage collection (requires --expose-gc flag)
this.memoryMonitor.forceGC();
}
ngOnDestroy() {
this.memoryMonitor.stopMonitoring();
}
}
Visual panel showing change detection statistics:
<ngx-cd-monitor-panel></ngx-cd-monitor-panel>
Features:
Visual panel showing memory usage:
<ngx-memory-leak-panel></ngx-memory-leak-panel>
Features:
| c/s (cycles/sec) | Status | Action |
|---|---|---|
| < 10 | ✅ Excellent | No action needed |
| 10-50 | ⚠️ Acceptable | Monitor |
| 50-100 | 🔶 Concerning | Investigate |
| > 100 | 🚨 Critical | Fix immediately |
Common issues:
OnPush change detection strategy| Trend %/min | Status | Action |
|---|---|---|
| < 0 | ✅ Decreasing (GC working) | OK |
| 0-2 | ✅ Stable | OK |
| 2-5 | ⚠️ Suspicious growth | Investigate |
| > 5 | 🚨 Leak detected | Fix immediately |
Common issues:
// ❌ BAD
ngOnInit() {
this.service.data$.subscribe(data => this.data = data);
}
// ✅ GOOD - Option 1: takeUntil
private destroy$ = new Subject<void>();
ngOnInit() {
this.service.data$
.pipe(takeUntil(this.destroy$))
.subscribe(data => this.data = data);
}
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
// ✅ GOOD - Option 2: async pipe (preferred)
@Component({
template: `<div>{{ data$ | async }}</div>`
})
export class MyComponent {
data$ = this.service.data$;
}
// ❌ BAD - getter called on every CD cycle
get total(): number {
return this.items.reduce((sum, item) => sum + item.price, 0);
}
// ✅ GOOD - computed once
total = 0;
ngOnChanges() {
this.total = this.items.reduce((sum, item) => sum + item.price, 0);
}
// ❌ BAD - Default strategy checks on every event
@Component({
changeDetection: ChangeDetectionStrategy.Default
})
// ✅ GOOD - OnPush only checks on input changes
@Component({
changeDetection: ChangeDetectionStrategy.OnPush
})
// ❌ BAD
ngOnInit() {
window.addEventListener('resize', this.onResize);
}
// ✅ GOOD
ngOnInit() {
window.addEventListener('resize', this.onResize);
}
ngOnDestroy() {
window.removeEventListener('resize', this.onResize);
}
import { isDevMode } from '@angular/core';
@Component({
template: `
@if (isDevMode()) {
<ngx-cd-monitor-panel></ngx-cd-monitor-panel>
<ngx-memory-leak-panel></ngx-memory-leak-panel>
}
`
})
// Monitor only specific components
@Component({
template: `
<div [cdMonitor]="shouldMonitor ? 'MyComponent' : null">
<!-- Content -->
</div>
`
})
export class MyComponent {
shouldMonitor = !environment.production;
}
// Lower threshold for critical components
<div cdMonitor="CriticalComponent" [cdMonitorThreshold]="30">
<!-- Lower threshold = earlier warnings -->
</div>
import {
ChangeDetectionMonitorService,
MemoryLeakDetectorService
} from 'ngx-performance-diagnostics';
@Component({/*...*/})
export class DiagnosticsComponent implements OnInit {
constructor(
private cdMonitor: ChangeDetectionMonitorService,
private memoryMonitor: MemoryLeakDetectorService
) {}
ngOnInit() {
// Start memory monitoring
this.memoryMonitor.startMonitoring();
// Check every 10 seconds
setInterval(() => {
const cdReport = this.cdMonitor.exportStats();
const memReport = this.memoryMonitor.exportReport();
// Send to analytics, log to console, etc.
this.sendToAnalytics({ cd: cdReport, memory: memReport });
}, 10000);
}
sendToAnalytics(data: any) {
// Your analytics implementation
}
}
exportDiagnostics() {
const report = {
timestamp: new Date().toISOString(),
changeDetection: JSON.parse(this.cdMonitor.exportStats()),
memory: JSON.parse(this.memoryMonitor.exportReport()),
userAgent: navigator.userAgent,
url: window.location.href
};
// Download or send to server
this.downloadReport(report);
}
No special configuration needed! The library is built with strict mode and full type safety.
Works with:
Contributions are welcome! Please read our Contributing Guide for details.
# Clone repository
git clone https://github.com/maciekv/ngx-performance-diagnostics.git
cd ngx-performance-diagnostics
# Install dependencies
npm install
# Build library
npm run build
# Run tests
npm test
MIT © [Maciej Osytek]
Built for the Angular community with ❤️
Happy Debugging! 🐛🔍
FAQs
Angular library for detecting performance issues, change detection cycles, and memory leaks
We found that ngx-performance-diagnostics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.