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

rss memory huge increase since 0.1.42+ ? #735

Closed
meloalright opened this issue Oct 19, 2023 · 1 comment · Fixed by #786
Closed

rss memory huge increase since 0.1.42+ ? #735

meloalright opened this issue Oct 19, 2023 · 1 comment · Fixed by #786

Comments

@meloalright
Copy link
Contributor

meloalright commented Oct 19, 2023

Use this case

const { createCanvas } = require('@napi-rs/canvas')

async function main() {
    const canvas = createCanvas(300, 320)
    const ctx = canvas.getContext('2d')

    ctx.lineWidth = 10
    ctx.strokeStyle = '#03a9f4'
    ctx.fillStyle = '#03a9f4'

    ctx.strokeRect(75, 140, 150, 110)

    ctx.fillRect(130, 190, 40, 60)

    ctx.beginPath()
    ctx.moveTo(50, 140)
    ctx.lineTo(150, 60)
    ctx.lineTo(250, 140)
    ctx.closePath()
    ctx.stroke()
    await canvas.encode('png')
}

async function bench() {
    console.log('before', process.memoryUsage())
    for (let i = 0; i < 1000; i++) {
        await main()
    }
    console.log('after', process.memoryUsage())
}

bench()

when using @napi-rs/[email protected]

before {
  rss: 41500672,
  heapTotal: 5509120,
  heapUsed: 5015784,
  external: 372846,
  arrayBuffers: 37937
}
after {
  rss: 116674560,
  heapTotal: 6041600,
  heapUsed: 4042200,
  external: 2749665,
  arrayBuffers: 10458
}

when using @napi-rs/[email protected]

before {
  rss: 40894464,
  heapTotal: 5509120,
  heapUsed: 5015976,
  external: 372846,
  arrayBuffers: 37937
}
after {
  rss: 358780928,
  heapTotal: 6041600,
  heapUsed: 4042216,
  external: 2749665,
  arrayBuffers: 10458
}

0.1.41 -> 0.1.42 the rss usage 200% increasement in this case

my device: Node.js v16.20.2 | Linux x86_64 GNU/Linux | AMD EPYC 7Y83 64-Core Processor | MemTotal 25339608 kB

in this case 0.1.40 ~ 0.1.41 is ok, 0.1.42 ~ 0.1.44 will see the increasement

@gc
Copy link

gc commented Oct 24, 2023

Duplicate #716

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

Successfully merging a pull request may close this issue.

2 participants