Freeing Memory

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
hrcap
Posts: 141
Joined: Mon Jan 14, 2019 5:20 pm

Freeing Memory

Post 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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10422
Joined: Fri Feb 19, 2010 10:17 am

Re: Freeing Memory

Post by richmond62 »

Flush

Look in the inbuilt Dictionary.
hrcap
Posts: 141
Joined: Mon Jan 14, 2019 5:20 pm

Re: Freeing Memory

Post by hrcap »

Hi Richmond

Thank you for the swift reply, flush doesnt appear to be in the dictionary.

Many Thanks
PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Sun Feb 20, 2011 4:26 pm
Contact:

Re: Freeing Memory

Post 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.

:idea: 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
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Freeing Memory

Post 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:

Code: Select all

wait 10 millisecs with messages 
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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
hrcap
Posts: 141
Joined: Mon Jan 14, 2019 5:20 pm

Re: Freeing Memory

Post 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.
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Freeing Memory

Post 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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Freeing Memory

Post 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
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10504
Joined: Wed May 06, 2009 2:28 pm

Re: Freeing Memory

Post by dunbarx »

Is this a Windows thing only?

Craig
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Freeing Memory

Post 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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Post Reply