# Memory Hog

**URL:** <https://forum.beeminder.com/t/memory-hog/5231>\
**Category:** Bugabee\
**Created:** [April 16, 2019, 4:49pm UTC](https://forum.beeminder.com/t/memory-hog/5231 "2019-04-16T16:49:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![phi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/phi/32/2586_2.png) [@phi](https://forum.beeminder.com/u/phi)\
**Post date:** [April 16, 2019, 4:49pm UTC](https://forum.beeminder.com/t/memory-hog/5231/1 "2019-04-16T16:49:43Z")

</div>

There be dragons at this goal:  
[https://www.beeminder.com/phi/spiht](https://www.beeminder.com/phi/spiht)

First a screenshot of what I am looking at right now:

 ![PastedGraphic-3](https://us1.discourse-cdn.com/flex019/uploads/beeminder/original/2X/6/6f9e334308b532fec23a5cf4f27b1a5ea9dcd037.png)

I restarted Safari to no avail.  
I am now getting the beachball of death.  
The dashboard itself is working fine and so are other goals. All that I have tried.  
It’s just my spiht goal that leaves the page partially blank and gets my CPU fans spinning.  
I opened it to check if the datapoint got logged after Beemios / BeeSwift crashed when I tapped Add Datapoint in the stopwatch.  
What a coincidence 🙄

Jeez look at the memory footprint! Again, i **just** restarted Safari.

 ![PastedGraphic-4](https://us1.discourse-cdn.com/flex019/uploads/beeminder/original/2X/4/4d5afc6b4a48265d3f0d830b7abcb64cd919f1bc.jpeg)  
You really like to put these memory hogs in there, don’t you 😉 Something something Visual Road Editor…

It does work in Chrome if that’s any help.

---

<div class="post-metadata">

**Author:** ![eugeniobruno](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@eugeniobruno](https://forum.beeminder.com/u/eugeniobruno)\
**Post date:** [April 16, 2019, 6:27pm UTC](https://forum.beeminder.com/t/memory-hog/5231/2 "2019-04-16T18:27:41Z")

</div>

I tried to investigate this, and it’s weird: I think you’re hitting a bug in the svg renderer??? I must surely be wrong here.

Try just loading this: [https://bmndr.s3.amazonaws.com/uploads/31603da8-31e0-4348-9187-cfa4e8853a6a.svg](https://bmndr.s3.amazonaws.com/uploads/31603da8-31e0-4348-9187-cfa4e8853a6a.svg)

It completely freaking kills my firefox even if I close the tab! As you noted, it works fine in chrome.

---

<div class="post-metadata">

**Author:** ![phi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/phi/32/2586_2.png) [@phi](https://forum.beeminder.com/u/phi)\
**Post date:** [April 16, 2019, 10:55pm UTC](https://forum.beeminder.com/t/memory-hog/5231/3 "2019-04-16T22:55:16Z")

</div>

A bug in the SVG renderer haha! 😂 This is great.  
Following your link on **mobile** Safari I get this:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/beeminder/original/2X/e/ee556b17a8461bb63adbcbc263b6604fbec5ff2f.png)

And after a while of retrying it eventually gives up

---

<div class="post-metadata">

**Author:** ![bee](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/bee/32/41_2.png) [@bee](https://forum.beeminder.com/u/bee)\
**Post date:** [April 17, 2019, 4:33am UTC](https://forum.beeminder.com/t/memory-hog/5231/4 "2019-04-17T04:33:33Z")

</div>

It looks like the current version of the graph is loading fine. The svg file that @eugeniobruno linked to has been killed and replaced. Did you change any settings with the goal that affected the graph rendering (e.g. maybe t-min or something?) If there were something about the svg itself that’s causing the browser to fall on its face, that’s definitely something we want to flag and try to figure out!

---

<div class="post-metadata">

**Author:** ![phi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/phi/32/2586_2.png) [@phi](https://forum.beeminder.com/u/phi)\
**Post date:** [April 17, 2019, 5:17am UTC](https://forum.beeminder.com/t/memory-hog/5231/5 "2019-04-17T05:17:25Z")

</div>

Interesting, I hope somebody saved a copy of that svg file 😬

If memory serves I have logged one single datapoint on it after I reported the bug – but in any case that was before I last tried to access the linked SVG file (and took the iOS screenshot). A good while before. I wanna say hours.  
And I think before @eugeniobruno poked it.  
I remember that when I last tapped „Add Datapoint“ in the stopwatch screen of Beemios that a spinner showed up and it took an unusually long time for the spinner to disappear. Not that I actively remember ever having seen a spinner there but that might just be my memory playing tricks on me.

In any case: I have definitely **not changed any settings** of the goal (or graph or anything really).

---

<div class="post-metadata">

**Author:** ![eugeniobruno](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@eugeniobruno](https://forum.beeminder.com/u/eugeniobruno)\
**Post date:** [April 17, 2019, 7:29am UTC](https://forum.beeminder.com/t/memory-hog/5231/6 "2019-04-17T07:29:20Z")

</div>

This is the SVG file that crashed. Interestingly, while it crashed firefox on windows, it seems to render fine on firefox on linux.

[https://pastebin.com/raw/WFdc8zWj](https://pastebin.com/raw/WFdc8zWj)

The SVG file seems (to my layman eyes) deeply changed. The crashing version had some huge numbers in a path, while the non-crashing version does not:

Crashing:

 ![2019-04-17-093649_2559x152_scrot](https://us1.discourse-cdn.com/flex019/uploads/beeminder/original/2X/a/a1050de84d24aa2ae441276a986b11ac7c1e248d.png)

Non crashing:

 ![2019-04-17-093804_2548x134_scrot](https://us1.discourse-cdn.com/flex019/uploads/beeminder/original/2X/5/5d8434e268081426c3e821b4e0d4b4c3795f6359.png)

---

<div class="post-metadata">

**Author:** ![eugeniobruno](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@eugeniobruno](https://forum.beeminder.com/u/eugeniobruno)\
**Post date:** [April 17, 2019, 7:56am UTC](https://forum.beeminder.com/t/memory-hog/5231/7 "2019-04-17T07:56:29Z")

</div>

In the non-crashing svg, numbers are generally floats, and seem to all be under 17 bits anyway.

 ![2019-04-17-095359_1434x1047_scrot](https://us1.discourse-cdn.com/flex019/uploads/beeminder/original/2X/a/a2f2441e20a0fce63cb235d4b5ac60fe57f1d800.png)

In the crashing svg, numbers are all around 54 to 55 bits, but more interestingly, they are mostly integers:

 ![2019-04-17-095449_1419x1056_scrot](https://us1.discourse-cdn.com/flex019/uploads/beeminder/original/2X/2/222e46aedb9573565321765ded88df4d330e5615.png)

Could this be a 32bit overflow of some kind?

---

<div class="post-metadata">

**Author:** ![eugeniobruno](https://avatars.discourse-cdn.com/v4/letter/e/f475e1/32.png) [@eugeniobruno](https://forum.beeminder.com/u/eugeniobruno)\
**Post date:** [April 17, 2019, 9:15am UTC](https://forum.beeminder.com/t/memory-hog/5231/8 "2019-04-17T09:15:59Z")

</div>

I think I’ve mostly figure it out, and the problems are those big numbers, but it’s not an integer overflow. Turning them into floats doesn’t work, making them smaller does:

```
# if the token appears to be a big integer, make it smaller
def xform(tok):
    try:
        if int(tok) > 2 ** 50:
            return str(int(tok) / (2 ** 50))
    except:
        pass

    return tok

crashing = open("crash.svg").read()
crashing_toks = crashing.split(" ")

maybe_not_crashing_toks = [xform(tok) for tok in crashing_toks]
open("uncrashed.svg", "w").write(" ".join(maybe_not_crashing_toks))

```

To confirm, you could check (closing and reopening the browser between checks) these test files. I can reproduce on win10 with FF.

The original SVG kills it: [https://github.com/Eugenio-Bruno/svg\_crashing\_ff/blob/master/original.svg](https://github.com/Eugenio-Bruno/svg_crashing_ff/blob/master/original.svg)  
Just turning ints to floats still kills it: [https://github.com/Eugenio-Bruno/svg\_crashing\_ff/blob/master/int\_to\_float.svg](https://github.com/Eugenio-Bruno/svg_crashing_ff/blob/master/int_to_float.svg)  
Making the numbers smaller fixes it: [https://github.com/Eugenio-Bruno/svg\_crashing\_ff/blob/master/smaller\_nums.svg](https://github.com/Eugenio-Bruno/svg_crashing_ff/blob/master/smaller_nums.svg)

---

<div class="post-metadata">

**Author:** ![phi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/phi/32/2586_2.png) [@phi](https://forum.beeminder.com/u/phi)\
**Post date:** [April 17, 2019, 10:29am UTC](https://forum.beeminder.com/t/memory-hog/5231/9 "2019-04-17T10:29:08Z")

</div>

/me adds a streak to the “bitten by stringly typed data” list

---

<div class="post-metadata">

**Author:** ![saranli](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/saranli/32/954_2.png) [@saranli](https://forum.beeminder.com/u/saranli)\
**Post date:** [April 18, 2019, 8:33am UTC](https://forum.beeminder.com/t/memory-hog/5231/10 "2019-04-18T08:33:53Z")

</div>

Thank you all for the debugging help. My current guess is that in certain cases, the polynomial fit that we do for generating the aura fails and generates very large y coordinates. I will try to identify specific goal and datapoint examples that lead to this to fix it in the jsbrain code. These very large numbers should never have been there in the first place. Nevertheless, I will also put in place filter that clip the numbers written in the svg as above.

---

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [May 22, 2019, 5:44am UTC](https://forum.beeminder.com/t/memory-hog/5231/11 "2019-05-22T05:44:07Z")

</div>

Fixed!

> <https://twitter.com/beemuvi/status/1131071962237636610>

> <https://github.com/beeminder/road/issues/74>
