You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
funccontainsPath(p1, p2string) bool {
p1Clean:=simpleClean(p1)
p2Clean:=simpleClean(p2)
ifp1Clean==p2Clean {
returntrue
}
if!strings.HasPrefix(p1Clean, p2Clean) {
returnfalse
}
// Check if the next character after prefix is '/'returnlen(p1Clean) >len(p2Clean) &&p1Clean[len(p2Clean)] =='/'
}
Reduces peak memory.
What you expected to happen:
I expected the compiler to be smart enough not to make a memory allocation at all.
Steps to reproduce the issue:
Use syft.CreateSBOM to generate an SBOM.
Anything else we need to know?:
Environment:
Output of syft version: I'm using it as a library github.com/anchore/syft v1.18.2-0.20250108175148-b4e7b64d5ce0
What happened:

I'm using syft to generate an SBOM for container images, we are seeing OOM conditions due to a lot of heap memory.
All the allocations are coming from this line:
https://github.com/anchore/syft/blob/main/syft/internal/fileresolver/path_skipper.go#L146
Changing it from the original to this:
Reduces peak memory.
What you expected to happen:
I expected the compiler to be smart enough not to make a memory allocation at all.
Steps to reproduce the issue:
Use
syft.CreateSBOM
to generate an SBOM.Anything else we need to know?:
Environment:
syft version
: I'm using it as a librarygithub.com/anchore/syft v1.18.2-0.20250108175148-b4e7b64d5ce0
cat /etc/os-release
or similar):The text was updated successfully, but these errors were encountered: