Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Out of Memory Issue #2

Open
MathNewBalance opened this issue May 24, 2024 · 2 comments
Open

Out of Memory Issue #2

MathNewBalance opened this issue May 24, 2024 · 2 comments

Comments

@MathNewBalance
Copy link

Hi,

I am a big fan of the plugin and its super useful. However I am getting an issue with the plugin eventually running out of memory despite clearing and deleting structures after use and then flushing pending deletes. I wondered if you could give me any advice on how to fix this

Best wishes

Math Whittaker

@ErikSom
Copy link
Owner

ErikSom commented May 25, 2024

Hi @MathNewBalance!

Which operations do you use primarily? Would it be possible to create a simple repro with e.g a for loop that does the operations a 1000 times so we can easily figure out which functions to fix?

Best,

Erik

@MathNewBalance
Copy link
Author

MathNewBalance commented Jun 10, 2024

HI Erik,

Sorry for the slow reply, I have attached an example of the function I am running below. It runs every frame the mouse is moved over a canvas so been run pretty often

 UpdateOffset(MousePosition) {
        this.clearPolyTree();
        
        let i = 0;
        let v = 0;
        let OffsetedPath = undefined;
        let Distance = 0;

        
        this.SortPaths(MousePosition)
        this.OffsetingPaths.push_back(this.currentGraphic.path);

        for (i = 0; i < this.Graphics.length; i++) {
            try{
            this.OffsetingPaths.push_back(this.Graphics[i].path);
            }
            catch(err){
                console.log(err);
            }
        
        }
     
        for (i = 0; i < this.OffsetCount; i++) {
            Distance = this.OffsetGap * i;
            try{
            OffsetedPath = this.clipper2.InflatePathsD(this.OffsetingPaths, Distance, this.clipper2.JoinType.Miter, this.clipper2.EndType.Polygon, 100.0, 3, 5);
            }
            catch(err){
                console.log(err)
            }
            for (v = 0; v < OffsetedPath.size(); v++) {
                try{
                this.OffsetedPaths.push_back(OffsetedPath.get(v));
                }
                catch(err){
                    console.log(err);
                }
            }
            OffsetedPath.clear();
            OffsetedPath.delete();

        }

        this.ClipperObject.AddSubject(this.OffsetedPaths);
        this.ClipperObject.AddClip(this.ShapeBoundary);
        try{
            this.ClipperObject.ExecutePoly(this.clipper2.ClipType.Intersection, this.clipper2.FillRule.EvenOdd, this.PolyPath)
        }
        catch(err){
            console.log(err);
        }
        this.ClipperObject.Clear();
        this.ClipperObject.delete();
        this.FinalCount=  this.PolyPath.count();        
      
    }```

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

No branches or pull requests

2 participants