I have a document with some rather lengthy \lstlisting's (source code snippets). It looks really bad if there is a page break within a listing/snippet. Thus I tried to avoid page breaks in listings by putting the listings into a minipage ( Avoid page breaks in \lstlistings ).
However, on the other hand it looks really bad if consecutive long snippets with little text in between create very underfull vboxes and pages with only a few lines of text.
So basically I want to tell LaTeX that both extremes look rather bad, and that page breaks may be used sparingly to avoid bad cases of underfull vboxes but should be avoided/penalized. Right now I can totally ban page breaks or I can allow them, but then it is assumed they are "totally OK" and used a lot when they should be a last resort.
How can I fine-tune the badness of either alternative in order to get a visually pleasing result?