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

Row.PushCell leads to Memory Leak #813

Open
liangdy678 opened this issue Aug 1, 2024 · 1 comment
Open

Row.PushCell leads to Memory Leak #813

liangdy678 opened this issue Aug 1, 2024 · 1 comment

Comments

@liangdy678
Copy link

liangdy678 commented Aug 1, 2024

Hi,
when we merge some xlsx files or copy some cells,memory leak occurs in some application scenarios.

// PushCell adds a predefiend cell to the end of the Row
func (r *Row) PushCell(c *Cell) {
	r.cellStoreRow.Updatable()
	r.isCustom = true  
	r.cellStoreRow.PushCell(c) 
        // c.Row Still only points to the original Row.
        // c.Row -> c.Row.Sheet -> c.Row.Sheet.File , then blocks GC
}

we recommand adding a new function CopyCell

// CopyCell adds a predefiend cell to the end of the Row
func (r *Row) CopyCell(c *Cell) {
	r.cellStoreRow.Updatable()
	r.isCustom = true
        c.Row = r   // Release the reference to the original row,points to the target Row
	r.cellStoreRow.PushCell(c)
}

@tealeg tealeg added this to the v4 milestone Sep 14, 2024
@tealeg
Copy link
Owner

tealeg commented Sep 14, 2024

@liangdy678 - yes, I see. I hadn't anticipated this use case. I'll consider this for either v4 or the next minor release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants