# XD using 28 gigs of ram

**URL:** <https://forums.creativeclouddeveloper.com/t/xd-using-28-gigs-of-ram/1497>\
**Category:** UXP Plugin API\
**Tags:** bug\
**Created:** [December 14, 2019, 4:20pm UTC](https://forums.creativeclouddeveloper.com/t/xd-using-28-gigs-of-ram/1497 "2019-12-14T16:20:55Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Velara](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/velara/32/1278_2.png) [@Velara](https://forums.creativeclouddeveloper.com/u/Velara)\
**Post date:** [December 18, 2019, 7:30am UTC](https://forums.creativeclouddeveloper.com/t/xd-using-28-gigs-of-ram/1497/4 "2019-12-18T07:30:13Z")

</div>

It sounds like an infinite loop and unreleased memory.

Does UXP have a script timeout limit? I think the browsers show a prompt if a script runs over a certain amount of time.

I was able to break up large loops by using promises to allow the user to cancel the operation if it’s taking too long.

In the [log utilities](http://forums.creativeclouddeveloper.com/t/statistics-plugin-and-plugin-developer-utilities/621/5) you can use a pseudo [sleep](https://github.com/velara3/xd-examples/blob/c205c1d5c1238b5db33486443f97c45bddcd4fa7/statistics/log.js#L949) function:

```
async function myProcessorIntensiveFunction(data) {
	let commands = require("commands");

	var items = [];

	// do stuff
	for(var index=0; index < items.length; index++) {
		// stuff 

		// give UI a chance to avoid the UI locking up 
		await sleep(1);
		showProgressInfo();

		if (cancelRunningProcess) {
			cancel();
			break;
		}
	}
}

// use async function with await
async function startButtonClickHandler(event) {
	showCancelButton();
	await myProcessorIntensiveFunction(data);
}

// cancel button click handler
async function cancelButtonClickHandler(event) {
	cancelRunningProcess = true;
	hideCancelButton();
}

```

If you are creating a lot of objects keep track by updating your UI instead of dumping to the console.

---

_[View the full topic](https://forums.creativeclouddeveloper.com/t/xd-using-28-gigs-of-ram/1497)._
