4.9.1 The basics

A window can be created by calling the function newwin. It
doesn’t draw anything on the screen initially. It allocates memory
for a structure to manipulate the window and updates the structure with
data regarding the window, like it’s size, position, etc.

The function newwin, like initscr, returns a
#<window>. Just like the stdscr created by
initscr, the window created by newwin can be used in any
procedure that takes a window argument. The window returned by
newwin needs to remain in scope for as long as the window is to
be used. If it is garbage collected, the memory associated with the
window will eventually be freed.

The memory associated with a window can be more quickly freed by
explicitly calling delwin. It will deallocate the memory
associated with the window structure. Any further attempts to then
use that window will cause an error.