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

[BUG] Get Rows function #1874

Closed
iraj720 opened this issue Apr 11, 2024 · 1 comment
Closed

[BUG] Get Rows function #1874

iraj720 opened this issue Apr 11, 2024 · 1 comment

Comments

@iraj720
Copy link
Contributor

iraj720 commented Apr 11, 2024

image_2024_04_11T08_13_58_086Z

there is a problem when using these kind of .xlsx files
in GetRows funciton it will add all rows and it will allocate huge amount of memory and then it will use only 0:max elements untill GC clocks
makes it unable to run service with limited memory

here is the file to reproduce it :

cost_center_matrix.xlsx

  1. add the following lines to (rows.go#L77):
    fmt.Println(max)
    fmt.Println(len(results))
  2. read it normally and check the memory usage with this code after reading it:
    var memStats runtime.MemStats
    runtime.ReadMemStats(&memStats)
    fmt.Printf("memory allocated: %d\n", memStats.Alloc)
    runtime.GC()
    runtime.ReadMemStats(&memStats)
    fmt.Printf("memory allocated 2: %d\n", memStats.Alloc)

difference between 2 prints is the unnecessary allocation

https://github.com/qax-os/excelize/blob/master/rows.go#L61-L79

@xuri
Copy link
Member

xuri commented Apr 15, 2024

Thanks for your pull request. I have merged this, and this patch will be released in the next version.

@xuri xuri moved this to Performance in Excelize v2.9.0 Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Performance
Development

No branches or pull requests

2 participants