Skip to content

Print attempted allocation size when panicing OOM #3236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

anuraaga
Copy link
Contributor

No description provided.

@dgryski
Copy link
Member

dgryski commented Oct 18, 2022

For consistency, we should probably define something like this in runtime/panic.go:

func oomPanic(size uintptr) {
                     // pretend to be a runtime panic, but without allocating
                     printstring("panic: runtime error: out of memory allocating ")
					printuint64(uint64(size))
					println(" bytes")
					abort()

}

but otherwise I like this idea.

@anuraaga
Copy link
Contributor Author

Thanks, did that and added to gc_leaking too

Copy link
Member

@dgryski dgryski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aykevl
Copy link
Member

aykevl commented Oct 18, 2022

I would like to check the code size impact of this change before accepting it.

@deadprogram
Copy link
Member

@aykevl could you please perform your check so we can unblock this PR?

@dgryski
Copy link
Member

dgryski commented Dec 7, 2022

Changing my mind on this. It seems unlikely that we particularly care about the last straw to break the camels back, rather than the story about all the other allocations that are filling up the heap.

@anuraaga
Copy link
Contributor Author

anuraaga commented Dec 7, 2022

The main reason for this is to easily know it is indeed out of memory and not a too huge allocation, e.g. some logic bug causing a 6GB allocation

@aykevl
Copy link
Member

aykevl commented Dec 21, 2022

I did a quick check and this change adds around 100 bytes of binary size in most cases, and sometimes much more.

Changing my mind on this. It seems unlikely that we particularly care about the last straw to break the camels back, rather than the story about all the other allocations that are filling up the heap.

Yes indeed. The last allocation is not the full story. It does catch very large allocations but that's a very specific error. While I agree this change will be useful in some specific cases, I do not think we should add this error message to every binary compiled with TinyGo (which might already be very tight on space).

@anuraaga
Copy link
Contributor Author

Ok no problem. #3302 is more important btw :)

@anuraaga anuraaga closed this Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants