Page 1 of 1
Freeing Memory
Posted: Sun Aug 10, 2025 8:50 pm
by hrcap
Hi All
I hope everyone is well.
I have a script which repeat multiple times printing PDFs. at the end of the repeat the printing is closed.
If I carry out this script multiple times LiveCode crashes.
I opened up task manager and watched what happened each time and each time the script is run the memory used by LC increases until eventually LC is using so much memory that it crashes.
• I have tried closing the stack where the print script is running after each operation to see if it would free up the memory, but it doesnt.
• I have looked through the variables to make sure there are no large ones remaining each time
I cant figure out what or where LC is holding in memory or where it is holding it, any ideas?
Many Thanks
Re: Freeing Memory
Posted: Sun Aug 10, 2025 8:51 pm
by richmond62
Flush
Look in the inbuilt Dictionary.
Re: Freeing Memory
Posted: Sun Aug 10, 2025 9:04 pm
by hrcap
Hi Richmond
Thank you for the swift reply, flush doesnt appear to be in the dictionary.
Many Thanks
Re: Freeing Memory
Posted: Mon Aug 11, 2025 3:49 am
by PBH
'flushEvents' is in the dictionary, it should show up when you search for 'flush', I'm not totally sure that would help in this case, but I could be wrong.

Just a thought, are you using 'open printing to PDF' and then using 'close printing' once the PDF is sent to the printer?
If you are not closing the print routine each time I could see that eating up memory, although I haven't tested it personally
Paul
Re: Freeing Memory
Posted: Mon Aug 11, 2025 3:58 am
by FourthWorld
For some operations LC will free up memory at idle. If that's at the heart of what you're seeing there, you might consider breaking your handler's loop into something that can use a timer. Total throughput time should be nearly the same, but it may provide just enough of an idle break to clean up the memory hooks to completed PDFs.
Thinking about this further, a simpler option might be to try adding this in your loop:
If we're lucky that may surrender enough time back to the OS to clean up the PDF load for the next iteration.
Let us know how that works out.
Re: Freeing Memory
Posted: Mon Aug 11, 2025 7:39 am
by hrcap
Hi Richard
Thank you,
The memory used by LC maintains even after the operation is complete…
- pdf printing started
- task manager disk space used by Livecode increases on each repeat when a pdf is printed
- pdf printing finishes
- LC sits their doing nothing but still displaying in task manager that it is using a lot of disk space
… if I then run the operation again, yet more disk space is added to LC, until eventually LC crashes.
I can’t think of any reason why LC, would still be using disc space after the operation completes.
Re: Freeing Memory
Posted: Mon Aug 11, 2025 8:48 am
by FourthWorld
Disc space or memory?
So you have a recipe we can run to reproduce this?
With a recipe stack, add that to a bug report and the team can usually address such issues quickly.
Re: Freeing Memory
Posted: Mon Aug 11, 2025 8:56 am
by bn
There are some reports of memory not being freed when printing to PDF and it looks like it is currently being looked at (awaiting test):
https://quality.livecode.com/show_bug.cgi?id=23088
Scroll to the bottom of the lenghty bug reports.
KInd regards
Bernd
Re: Freeing Memory
Posted: Mon Aug 11, 2025 2:35 pm
by dunbarx
Is this a Windows thing only?
Craig
Re: Freeing Memory
Posted: Mon Aug 11, 2025 6:21 pm
by FourthWorld
Thank you for posting that link, Bernd.
dunbarx wrote: ↑Mon Aug 11, 2025 2:35 pm
Is this a Windows thing only?
That it how it's listed in the report.