Skip to content

Commit

Permalink
fix(backend): fix memory issues with huge page sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
burdiyan committed Dec 17, 2024
1 parent c3baadd commit 8cf3e86
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/api/documents/v3alpha/documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (srv *Server) ListRootDocuments(ctx context.Context, in *documents.ListRoot
}

out := &documents.ListRootDocumentsResponse{
Documents: make([]*documents.DocumentListItem, 0, in.PageSize),
Documents: make([]*documents.DocumentListItem, 0, min(in.PageSize, 300)), // Avoid allocating huge slice if huge page size was requested. Number is arbitrary.
}

namespaceGlob := "hm://*"
Expand Down Expand Up @@ -314,7 +314,7 @@ func (srv *Server) ListDocuments(ctx context.Context, in *documents.ListDocument
}

out := &documents.ListDocumentsResponse{
Documents: make([]*documents.DocumentListItem, 0, in.PageSize),
Documents: make([]*documents.DocumentListItem, 0, min(in.PageSize, 300)), // Avoid allocating huge slice if huge page size was requested. Number is arbitrary.
}

namespaceGlob := "hm://" + ns.String() + "*"
Expand Down

0 comments on commit 8cf3e86

Please sign in to comment.