Skip to content

[BUG] Get Rows function #1874

@iraj720

Description

@iraj720
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions