rust-pretty-assertions icon indicating copy to clipboard operation
rust-pretty-assertions copied to clipboard

memory allocation of 96543189696 bytes failed

Open aminya opened this issue 2 years ago • 5 comments

When an object is big, the package fails to allocate its debug representation of it in the memory, so it fails.

assert_eq!(big_obj, big_obj2)

The solution would be to act like the standard assert_eq, which doesn't fail or maybe represent the needed subset only. Related to #19

aminya avatar Sep 22 '23 05:09 aminya

It's questionable how we proceed here - as we do more processing that the standard assert_eq, there will always be some point where we run out of memory faster and panic.

There's probably some tweaking we can do, but my understanding is that we'll have to allocate a contiguous range of memory for these debug implementations somewhere, plus the overhead of diffing, formatting etc.

I think think I would have to know more about this 96.5GB representation, and why you want to use assert_eq to diff it's debug format, as that's well outside what this library is targeted at.

tommilligan avatar Sep 22 '23 14:09 tommilligan

It is just a indextree with nested children. The object itself is not crazy big, but the Debug representation seems to be way outside the memory limits.

aminya avatar Sep 22 '23 18:09 aminya

I have noticed that this crate shows the Debug representation of the two objects fully before showing the diff. I suspect that's why it fails. I only care about the diff and not the whole object.

Related to #114

aminya avatar Sep 24 '23 03:09 aminya

The reason for this is the use of diff::chars. It allocates a Vec of left.len() * right.len() i32s. The data compared here is probably just around 155 kB, leading to an insane 90 GiB Vec. The logic already starts getting a problem with just a couple of kB.

cschramm avatar Jan 31 '24 21:01 cschramm

@cschramm Opened a ticket upstream to discuss this.

aminya avatar Jan 31 '24 23:01 aminya