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

[Add font recycling especially for CJK] Possible memory leak (related to fonts?) #93

Open
ghost opened this issue Jul 14, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 14, 2020

When trying padofcode/padoftext examples I noticed that when you paste a lot of text, and then remove it, the memory usage will forever stay much higher.

Steps:
Run padofcode/padoftext
Paste a big amount of text (RAM usage goes higher)
Remove all text -> RAM usage is still the same

@ghost ghost closed this as completed Jul 14, 2020
@treeform treeform reopened this Jul 14, 2020
@ghost
Copy link
Author

ghost commented Jul 14, 2020

With dumpNumberOfInstances I get:

[Heap] seq[GlyphPosition]: #3; bytes: 10833856
[Heap] string: #107367; bytes: 4692843
[Heap] seq[Rune]: #1; bytes: 262176
[Heap] seq[float32]: #1035; bytes: 110712
[Heap] Glyph: #911; bytes: 94744
[Heap] seq[Segment]: #52; bytes: 61968
[Heap] KeyValuePairSeq[system.int, system.int]: #1; bytes: 49184
[Heap] KeyValuePairSeq[system.string, font.Glyph]: #1; bytes: 49184
[Heap] seq[PathCommand]: #37; bytes: 18544
[Heap] seq[uint8]: #1; bytes: 16416
[Heap] seq[float64]: #2; bytes: 16064
[Heap] seq[uint16]: #2; bytes: 14400
[Heap] KeyValuePairSeq[hashes.Hash, vmath.Rect]: #1; bytes: 8224
[Heap] seq[int]: #1; bytes: 8224
[Heap] seq[Glyph]: #1; bytes: 7320
[Heap] KeyValuePairSeq[hashes.Hash, vmath.Vec2]: #1; bytes: 6176
[Heap] KeyValuePairSeq[system.string, system.string]: #1; bytes: 6176
[Heap] seq[LongHorMetricRecrod]: #1; bytes: 4128
[Heap] KeyValuePairSeq[system.string, perf.CountSize]: #1; bytes: 4128
[Heap] seq[uint32]: #1; bytes: 4128
[Heap] KeyValuePairSeq[system.string, types.Chunk]: #1; bytes: 2592
[Heap] seq[seq[Segment]]: #37; bytes: 2368
[Heap] seq[NameRecord]: #1; bytes: 1568
[Heap] KeyValuePairSeq[system.string, font.Font]: #1; bytes: 1568
[Heap] seq[bool]: #4; bytes: 1520
[Heap] Node: #3; bytes: 1056
[Heap] seq[Uniform]: #2; bytes: 768
[Heap] Context: #1; bytes: 448
[Heap] seq[Mat4]: #1; bytes: 288
[Heap] seq[Node]: #5; bytes: 216
[Heap] seq[ShaderAttrib]: #2; bytes: 192
[Heap] TextBox: #1; bytes: 144
[Heap] Font: #1; bytes: 144
[Heap] OtfFont: #1; bytes: 136
[Heap] OS2Table: #1; bytes: 128
[Heap] StringStream: #1; bytes: 120
[Heap] seq[Texture]: #1; bytes: 104
[Heap] seq[string]: #2; bytes: 96
[Heap] Shader: #2; bytes: 96
[Heap] Keyboard: #1; bytes: 88
[Heap] HeadTable: #1; bytes: 80
[Heap] seq[EncodingRecord]: #1; bytes: 64
[Heap] TimeSeries: #2; bytes: 64
[Heap] MaxpTable: #1; bytes: 56
[Heap] Mouse: #1; bytes: 52
[Heap] CmapTable: #1; bytes: 48
[Heap] HheaTable: #1; bytes: 44
[Heap] HmtxTable: #1; bytes: 32
[Heap] NameTable: #1; bytes: 32
[Heap] TableRef[system.string, perf.CountSize]: #1; bytes: 32
[Heap] TableRef[system.string, system.string]: #1; bytes: 32
[Heap] LocaTable: #1; bytes: 24
[Heap] GlyfTable: #1; bytes: 24
[Heap] total number of bytes: 16282819
[Heap] allocs/deallocs: 193737964/193627474

@ghost
Copy link
Author

ghost commented Jul 14, 2020

Tested with refc/refc+useMalloc/orc/orc+useMalloc on latest devel, all show the same behaviour. Not sure if this is a Nim regression or fidget (or typography) bug

@treeform
Copy link
Owner

treeform commented Oct 22, 2020

I don't clean up letter after they are rasterized even if you remove it from text. This is usually not a problem for alphabet based languages but could be an issue for CJK. I don't have a good solution for this yet.

@treeform treeform changed the title Possible memory leak (related to fonts?) [Add font recycling especially for CJK] Possible memory leak (related to fonts?) Oct 22, 2020
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

No branches or pull requests

1 participant