Why does VSCode freeze when there is a ton of terminal output (Ubuntu)?

I have a program that prints the rgba of all the pixels in an image using PIL. The problem is that when I run the program in VSCode, it prints a second or so of output, and then freezes. My whole computer then freezes, and I have to power it off and restart it.

However, when I run the program in the GNOME terminal, it completes successfully. Could anyone tell me why VSCode does this, and if there is a way to prevent it? (in other words, what is the difference between the GNOME terminal and the VSCode terminal?)

The code:

import PIL
from PIL import Image

image = Image.open("/home/user/i.jpg")
for i in image.getdata():
    print(i, end="")

Here is the image I am using:

/home/user/i.jpg

This problem is not specific to the image code, this code is just a good way to demonstrate the kind of code that causes this error. I’m using Python 3.8.10 in VSCode 1.52.1 on an Ubuntu 20.04.2.

Answer

It looks like just because the picture which you are using is too large that caused too many outputs, I have tried some litter images and it works well.

Update:

The terminal was integrated into the VSCode. It has been customed, so it has different strategies such as memory strategy.

And looks like we should avoid outputs too much data in the integrated terminal in the VSCode. Some people have run across the same issue.

And it looks like increasing the size of the terminal panel is helpful to outputs the data more smoothly.