Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • H html-validate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 22
    • Issues 22
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Scheduled maintenance on the database layer will take place on 2022-07-02. We expect GitLab.com to be unavailable for up to 2 hours starting from 06:00 UTC. Kindly follow our status page for updates and read more in our blog post.

  • html-validate
  • html-validate
  • Issues
  • #106
Closed
Open
Created Feb 17, 2021 by Leonid Beschasny@lbeschastny

Memory leak during validation

Memory is leaking during html validation

Reduced test-case

const {HtmlValidate} = require('html-validate');

let ticks = 0;

const tick = () => {
	const htmlValidate = new HtmlValidate({});
	htmlValidate.validateString(
		'<!DOCTYPE html><html><head></head><body></body></html>'
	);

	ticks++;
};

const report = () => {
	const {heapTotal} = process.memoryUsage();

	process.stdout.clearLine();
	process.stdout.cursorTo(0);
	process.stdout.write(`${ticks} ticks done, ${heapTotal} heap used`);
}

console.log('starting...')
setInterval(tick, 0);
setInterval(report, 1000);

Configuration

Any

Expected result

Memory should not leak, especially if new HtmlValidate instance is created for each validation.

Actual result

↪ node html-validate-test.js
starting...
54433 ticks done, 2149851136 heap used
<--- Last few GCs --->

[752639:0x3827310]  1388059 ms: Scavenge 2044.6 (2050.3) -> 2043.8 (2050.3) MB, 5.6 / 0.0 ms  (average mu = 0.333, current mu = 0.482) allocation failure 
[752639:0x3827310]  1388133 ms: Scavenge 2044.8 (2050.3) -> 2044.0 (2050.3) MB, 10.8 / 0.0 ms  (average mu = 0.333, current mu = 0.482) allocation failure 
[752639:0x3827310]  1388208 ms: Scavenge 2044.9 (2050.3) -> 2044.1 (2050.8) MB, 11.2 / 0.0 ms  (average mu = 0.333, current mu = 0.482) allocation failure

or faster version

↪ node --max-old-space-size=128 html-validate-test.js
starting...
2632 ticks done, 151437312 heap used
<--- Last few GCs --->

[752162:0x35a73f0]    80061 ms: Scavenge 115.8 (122.2) -> 111.6 (122.2) MB, 1.0 / 0.0 ms  (average mu = 0.379, current mu = 0.373) allocation failure 
[752162:0x35a73f0]    80077 ms: Scavenge 116.0 (122.2) -> 112.1 (122.2) MB, 1.1 / 0.0 ms  (average mu = 0.379, current mu = 0.373) allocation failure 
[752162:0x35a73f0]    80092 ms: Scavenge 116.2 (122.2) -> 111.9 (131.9) MB, 1.1 / 0.0 ms  (average mu = 0.379, current mu = 0.373) allocation failure 

Version

  • node: 12.18.1
  • html-validate: 4.6.0
Edited Feb 17, 2021 by Leonid Beschasny
Assignee
Assign to
Time tracking