# Caching windows on StartUp

**URL:** <https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413>\
**Category:** Ignition\
**Created:** [November 13, 2012, 4:34pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413 "2012-11-13T16:34:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [November 13, 2012, 4:34pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413/1 "2012-11-13T16:34:18Z")

</div>

I have a number of layouts that need to be opened, closed, and cached on Startup so they don’t bog the project down when switching between them.  
I have set these windows caching to ALWAYS.  
I also thought the method to do this would be to open these windows on startup and run a StartUP client script to close each one of them… Sometimes the script misses closing ALL of the windows though.  
How should I pull this off?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 13, 2012, 5:33pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413/2 "2012-11-13T17:33:29Z")

</div>

When you are closing the windows, are you looping through the opened windows or closing a static list? You might have to close the windows after a few seconds or so, something like:`def doLater():
    import system
    system.nav.closeWindow("WindowName1")
    system.nav.closeWindow("WindowName2")
    system.nav.closeWindow("WindowName3")
    ....
system.util.invokeLater(doLater, 5000)`That will do it after 5 seconds.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [November 14, 2012, 2:58pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413/3 "2012-11-14T14:58:28Z")

</div>

This seems to work okay. Sometimes I get stuck in one of the windows I want to close affter my startup so I changed the timer to 10 seconds and haven’t yet had an issue but I was wondering if it’s possible to wait until all windows have been loaded before executing all the close scripts in order to make certain I am not prematurely firing this script before the windows have been loaded.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 14, 2012, 4:51pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413/4 "2012-11-14T16:51:19Z")

</div>

You can probably look at:`windows = system.gui.getOpenedWindowNames()
print len(windows)`You can see how many are in the list or loop through them.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [November 14, 2012, 8:43pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413/5 "2012-11-14T20:43:01Z")

</div>

ok, using this just seems to lock up my client or lock it up after saving the project,

`import system
windows = system.gui.getOpenedWindowNames()
while len(windows) != 2:
    system.nav.closeWindow("1")
    system.nav.closeWindow("2")
    windows = system.gui.getOpenedWindowNames()`  
I want to close everything except the Header and main page.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 14, 2012, 10:00pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413/6 "2012-11-14T22:00:22Z")

</div>

Try printing out the list of windows to see why it gets stuck.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [November 15, 2012, 6:09pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413/7 "2012-11-15T18:09:33Z")

</div>

sometimes just closing the list of windows in the  
def doLater called after 10 seconds does this.

Launches the client.  
opens the windows  
closes the entire client.

I’ve seen this twice but can’t explain why it happens unless it’s hitting up too much memory on my server having all these windows open at once.

If this is the case then I suppose I would have to stagger the open/close process to open and close them one at a time or something.  
it took me 6 minutes to open/close 9 windows ☹

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [November 15, 2012, 9:48pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413/8 "2012-11-15T21:48:13Z")

</div>

Seems like you’re jumping through hoops to cache all your windows, but then your client is running out of memory.

Have you thought about upgrading the client machine to increase performance?

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [November 15, 2012, 9:50pm UTC](https://forum.inductiveautomation.com/t/caching-windows-on-startup/5413/9 "2012-11-15T21:50:15Z")

</div>

Are you connecting over a particularly low bandwidth connection? Do you have large graphics or anything else that takes up a lot of data embedded in your windows? Any particularly slow queries? This raises the red flag that other bigger problems may exist.

> [@BigSchottkyD](#):
>
> it took me 6 minutes to open/close 9 windows ☹
