fix the problem with too many windows

limit the number of windows and amount of memory used