memory leak #1955

Closed
George874248 opened this Issue Aug 22, 2016 · 5 comments

Projects

None yet

4 participants

@George874248

Help us to manage our issues by answering the following:

<example>
    <div>
        <div each={item in data}>
            <div name="f1">{item.name}</div>
            <div name="f2">{item.name}</div>
            <div name="f3">{item.name}</div>
            <div name="f4">{item.name}</div>
            <div name="f5">{item.name}</div>
            <div name="f6">{item.name}</div>
            <div name="f7">{item.name}</div>
        </div>
    </div>


    <script>
        this.data = []

        this.on("mount", () => {
            setInterval(() => {
                this.data = this.generate()
                this.update()
            }, 3000)
        })

        this.on("update", () => {
            console.log(this)
        })

        this.generate = () => {
            var data = [];
            for (var i = 0; i < 50;  i++) {
                //data.push(Math.random())
                data.push({name: Math.random()})
            }
            return data
        }
    </script>
</example>

if i use array of objects in my loop, array of names in object "this" grow up.

for exapmle:

1 update:
this.f1.length = 50;
this.f2.length = 50;
this.f3.length = 50;
......

2 update
this.f1.length = 100;
this.f2.length = 100;
this.f3.length = 100;
......

3 update
this.f1.length = 150;
this.f2.length = 150;
this.f3.length = 150;
......

4 update
this.f1.length = 200;
this.f2.length = 200;
this.f3.length = 200;
......
5 update
this.f1.length = 250;
this.f2.length = 250;
this.f3.length = 250;
......

it's normal?
you can use my example tag to see result in console.

@rsbondi
Contributor
rsbondi commented Aug 22, 2016

This works correctly on next branch

@rsbondi rsbondi added the bug label Aug 22, 2016
@GianlucaGuarini
Member

@rsbondi can this issue be also fixed in riot2?

@GianlucaGuarini GianlucaGuarini added this to the 3.0.0 milestone Aug 28, 2016
@GianlucaGuarini
Member

@rsbondi @rogueg this issue still exists in riot@next I have updated the memory tests and having tags with ref attributes in a loop blows up the program memory after a couple updates. To check the issue you can run $ make perf-leaks

@rogueg
Member
rogueg commented Sep 4, 2016

Should be fixed now.

@GianlucaGuarini
Member

glory to @rogueg 😺

@GianlucaGuarini GianlucaGuarini pushed a commit that closed this issue Nov 22, 2016
@rogueg rogueg Unmount expressions in Tag instance attributes.
Like all other expressions a Tag has, these need to be unmounted when the Tag itself is unmounted. They're a little different, because they evaluate in the context of the Tag's parent; that's why we don't store them in `expressions`.

This fixes #1955
2710d28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment