Larger figure size cost more memory, why?

I am ploting lines with matplotlib,and the memory cost traps me.
i found it cost more memory if i maximize the figure?

Without knowing exactly what you are doing it is hard to be sure, but my guess is that two things are getting you.

First, making a bigger figure is simply more pixels both in the final output and in the intermediate data structures.

Second, Matplotlib uses a path-simplification algorithm that determines if the next point will have a visual effect or not (what it means to “have a visual effect” can be tuned via rcParams['path.simplify_threshold'], see Performance — Matplotlib 3.5.0 documentation for more details). Making the figure bigger while keeping the same data limits effectively increases the pixels-per-data-unit on the line and hence will cause fewer points to be simplified out (you could also keep the figure the same size and increase the DPI and get the same effect). If your data happened to be noisy at a level where the default size is sub-pixel and when maximized is bigger than a pixel you could see a big jump in resource usage as the line is no longer simplified. You may also benefit from tuning rcParams['agg.path.chunk_size'] (see Performance — Matplotlib 3.5.0 documentation).