Memory leak when search specific kanji (japanese hieroglyph)

When searching for kanji 誰 in deck (collection attached below hmm, how can I attach it?), app is stop responding, and used memory starts growing (AnkiMobile on android also freezes). Strange thing is, this deck originally from ankiweb, but with “original” version searching is ok. I checked inner sqlite databases, and content is slightly different

Steps to reproduce (be ready to kill app):

  • create empty profile
  • import attached deck
  • click Browse
  • insert kanji
  • press Enter
1 Like

It is caused by malformed clozes in that deck

Lines from text export of this deck:

「これは誰{{c1::{{c1::の}}}}か教えてください。」「それは私{{c1::{{c1::の}}}}です。」{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1::{{c1:: }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}	&quot;Please tell me whose this is.&quot;&quot;That is mine.&quot;		[context is understood by the speakers]	"の - Pronoun &#x27;one&#x27;"	"pronoun &#x27;one&#x27;<br> &#x27;reduced&#x27; noun"		Noun 1 + Pronoun + の (Noun 2)<br> If Noun 2 is understood through context: Noun 1 + の Noun 2	"

or

「テレビを見{{c1::{{c1::て}}}}シャワーを浴び{{c1::{{c1::て}}}}寝たんだ。」	&quot;I watched TV (and), took a shower, and slept.&quot;			Verb[て] + B	Sequence<br> and<br> and then<br> after		Verb[て] + Action/EventVerb[て] conjugations	"

Searching anything on those notes, like context is understood also causes a memory leak, so it does not have anything to do with the kanji character.

Also just searching your collection with this deck imported takes a ton of time. Selecting a card with those weird clozes also causes a memory leak in the browser.

4 Likes

Here is the stack dump when trying to kill the app while it is leaking:

blocked main thread for 1760ms:
  File "<string>", line 1, in <module>
  File "aqt", line 514, in run
  File "aqt", line 728, in _run
  File "aqt.webview", line 50, in cmd
  File "aqt.webview", line 157, in _onCmd
  File "aqt.webview", line 686, in _onBridgeCmd
  File "aqt.editor", line 514, in onBridgeCmd
  File "aqt.browser.browser", line 531, in <lambda>
  File "aqt.browser.browser", line 747, in onTogglePreview
  File "aqt.browser.previewer", line 68, in open
  File "aqt.browser.previewer", line 169, in render_card
  File "aqt.browser.previewer", line 370, in _render_scheduled
  File "aqt.browser.previewer", line 202, in _render_scheduled
  File "anki.cards", line 139, in question
  File "anki.cards", line 155, in render_output
  File "anki.template", line 225, in render
  File "anki.template", line 272, in _partially_render
  File "anki._backend_generated", line 1437, in render_existing_card
  File "anki._backend", line 169, in _run_command

The issue happens with 12 > stacked clozes - that takes about 3 seconds on my laptop. That grows exponentially.

I created an issue on github: Nested clozes cause exponentially growing html · Issue #3189 · ankitects/anki · GitHub

5 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.