diff --git a/pkg/convert/jfr/profile.go b/pkg/convert/jfr/profile.go index 1a0c94595f..90cdf62619 100644 --- a/pkg/convert/jfr/profile.go +++ b/pkg/convert/jfr/profile.go @@ -62,6 +62,9 @@ func loadJFRFromForm(r io.Reader, contentType string) (io.Reader, *LabelsSnapsho if err != nil { return nil, nil, err } + defer func() { + _ = f.RemoveAll() + }() jfrField, err := form.ReadField(f, "jfr") if err != nil { diff --git a/pkg/convert/pprof/profile.go b/pkg/convert/pprof/profile.go index ac3d368ec8..7be2d8a6db 100644 --- a/pkg/convert/pprof/profile.go +++ b/pkg/convert/pprof/profile.go @@ -186,14 +186,14 @@ func (p *RawProfile) loadPprofFromForm() error { return err } - // maxMemory 32MB. - // TODO(kolesnikovae): If the limit is exceeded, parts will be written - // to disk. It may be better to limit the request body size to be sure - // that they loaded into memory entirely. f, err := multipart.NewReader(bytes.NewReader(p.RawData), boundary).ReadForm(32 << 20) if err != nil { return err } + defer func() { + _ = f.RemoveAll() + }() + p.Profile, err = form.ReadField(f, formFieldProfile) if err != nil { return err