Skip to content

Commit

Permalink
fix: CGO Memory leak issue (#40)
Browse files Browse the repository at this point in the history
Co-authored-by: Bhargav Dodla <[email protected]>
  • Loading branch information
EXPEbdodla and Bhargav Dodla authored Sep 28, 2023
1 parent 6cf454c commit 4ce821b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions go/internal/feast/server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/feast-dev/feast/go/internal/feast"
"github.com/feast-dev/feast/go/internal/feast/model"
"github.com/feast-dev/feast/go/internal/feast/onlineserving"
"github.com/feast-dev/feast/go/internal/feast/server/logging"
"github.com/feast-dev/feast/go/protos/feast/serving"
prototypes "github.com/feast-dev/feast/go/protos/feast/types"
Expand Down Expand Up @@ -269,6 +270,14 @@ func (s *httpServer) getOnlineFeatures(w http.ResponseWriter, r *http.Request) {
return
}
}

go releaseCGOMemory(featureVectors)
}

func releaseCGOMemory(featureVectors []*onlineserving.FeatureVector) {
for _, vector := range featureVectors {
vector.Values.Release()
}
}

func (s *httpServer) Serve(host string, port int) error {
Expand Down
5 changes: 5 additions & 0 deletions go/internal/feast/transformation/transformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ func AugmentResponseWithOnDemandTransforms(
return nil, err
}
result = append(result, onDemandFeatures...)

// Release memory used by requestContextArrow
for _, arrowArray := range requestContextArrow {
arrowArray.Release()
}
}

return result, nil
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/feast/ui_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def shutdown_event():

ui_dir = importlib_resources.files(__name__) / "ui/build/"
# Initialize with the projects-list.json file
with open(ui_dir + "projects-list.json", mode="w") as f:
with open(str(ui_dir) + "projects-list.json", mode="w") as f:
projects_dict = {
"projects": [
{
Expand Down

0 comments on commit 4ce821b

Please sign in to comment.