Push/Pop Card versus Goto Card

Getting into LiveCode for iOS? Ask your questions here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
allengwinn
Posts: 30
Joined: Tue Aug 21, 2012 4:46 pm

Push/Pop Card versus Goto Card

Post by allengwinn » Sat Dec 29, 2018 10:29 pm

Is there a reason to use Push and Pop versus just a bunch of Goto's when moving from card to card without worrying about memory leaks? In other words, if I have a Main card with a button that launches another card and a button on that card that launches another card (etc.) but then have a "Home" button on each card that just does a Goto back to the Main card, am I inviting disaster or is that completely kosher? Is there something that should be used on exit from a card to destroy the memory it's using?

Sorry, I just come from a structured coding environment :)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6305
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Push/Pop Card versus Goto Card

Post by FourthWorld » Sat Dec 29, 2018 10:40 pm

All coding is structured. Languages differ only in how they're structured. :)

The "go" command (LC has no "goto") allows navigation to any card or stack.

The "push" and "pop" commands can be used for the subset of navigation where you specifically want to traverse a set of cards in inverse storage order.

Personally I almost never use "push" and "pop", but it may be just a matter of style. I just don't often have cases fitting what they do, and prefer to manage navigation more directly anyway.

Both options are likely very similar with regard to memory requirements. Command execution by itself adds little to the engine once the stack is loaded, with most memory being take up by media on cards and the rendering buffer for those cards. So either method will for the most part have the same RAM footprint.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 2573
Joined: Sat Feb 25, 2017 10:45 pm

Re: Push/Pop Card versus Goto Card

Post by bogs » Sat Dec 29, 2018 11:53 pm

FourthWorld wrote:
Sat Dec 29, 2018 10:40 pm
The "go" command (LC has no "goto") allows navigation to any card or stack.
Well, it doesn't have "goto" as one word, anyway :wink:
Selection_003.png
Go...to?
Only kidding ! Although, that is how I write it, I am probably alone in that group. I don't use any of the other abbreviations either. Don't ask, I can't explain it.
Image

allengwinn
Posts: 30
Joined: Tue Aug 21, 2012 4:46 pm

Re: Push/Pop Card versus Goto Card

Post by allengwinn » Sun Dec 30, 2018 2:32 am

Yeah, I was worried about memory leaks if you started doing too many "go to" :) cards. So if I repeatedly "go to" a main menu, I'm not increasing app storage... that's what I'm trying to determine. I'm writing an app that will make repeated visits to the main menu so I'm trying to be socially responsible :)

bogs
Posts: 2573
Joined: Sat Feb 25, 2017 10:45 pm

Re: Push/Pop Card versus Goto Card

Post by bogs » Sun Dec 30, 2018 2:20 pm

I think Hermann figured out how to get a memory leak with his latest experiment, but so far as I know, that is a self contained and specific circumstance. -hh's stuff really is over the top (and my head) :D
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6305
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Push/Pop Card versus Goto Card

Post by FourthWorld » Sun Dec 30, 2018 6:08 pm

When a stack file has been loaded into memory, the only additional memory needed is for rendering the card. Unless you have a large number of high res images, you probably won't see much impact on memory at all.

Any complex software has the potential for memory leaks, and LiveCode is no exception. But since LiveCode is used in many long-running contexts like industrial control systems, kiosks, etc., the core team gives high priority to fixing leaks when they're reported, and uses automated code review tools like Coverity to catch things like that during development before it's released.

I've had software made with LiveCode that's running continuously, performing tasks every five minutes, for several weeks at a time without a hiccup, and that's on very modest hardware with just 1GB RAM. I could probably run it for months, but I keep the system up to date and sometimes OS patches require reboot.

At the moment, I'm not aware of any leaks that have not been resolved, or at least in process to be resolved for the next release.

Should you find one please report it. But they're rare enough that you shouldn't need to worry about them when designing your app.

If you need to open a card, open the card. You'll be fine, regardless which syntax you use to open it.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6305
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Push/Pop Card versus Goto Card

Post by FourthWorld » Sun Dec 30, 2018 6:15 pm

bogs wrote:
Sun Dec 30, 2018 2:20 pm
I think Hermann figured out how to get a memory leak with his latest experiment, but so far as I know, that is a self contained and specific circumstance.
Do you recall how recent that was, and whether it was reported?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 2573
Joined: Sat Feb 25, 2017 10:45 pm

Re: Push/Pop Card versus Goto Card

Post by bogs » Sun Dec 30, 2018 11:04 pm

Well, as to how recent, it was part of this post in his "Succesful Test" area.
[-hh] wrote:
Fri Dec 28, 2018 5:39 am
JIGSAW PUZZLE 2d-video v_100
<sic>
Videos.
As above but without importing, use one of the nine built-in looping videos.
The segmenting of the video frames is done with canvas methods in javascript.
This will stress your CPU/GPU! It runs at about ten times faster in
the IDE with a browser widget, but sadly this is memory-leaking (5 MBytes
per second).
The HTML5 standalone runs at about two times faster in Safari
than Firefox or Chrome/Opera. Reduce the number of pieces if you have less
than 2-3 frames per second.
</sic>
As to whether or not he reported it, or is just going to fix it hisself, thats one I'll leave to the man who found it to answer :wink:
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6305
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Push/Pop Card versus Goto Card

Post by FourthWorld » Mon Dec 31, 2018 1:08 am

bogs wrote:
Sun Dec 30, 2018 11:04 pm
Well, as to how recent, it was part of this post in his "Succesful Test" area.
[-hh] wrote:
Fri Dec 28, 2018 5:39 am
JIGSAW PUZZLE 2d-video v_100
<sic>
Videos.
As above but without importing, use one of the nine built-in looping videos.
The segmenting of the video frames is done with canvas methods in javascript.
This will stress your CPU/GPU! It runs at about ten times faster in
the IDE with a browser widget, but sadly this is memory-leaking (5 MBytes
per second).
The HTML5 standalone runs at about two times faster in Safari
than Firefox or Chrome/Opera. Reduce the number of pieces if you have less
than 2-3 frames per second.
</sic>
As to whether or not he reported it, or is just going to fix it hisself, thats one I'll leave to the man who found it to answer :wink:
Curious. Being specific to the browser object, it seems the leak is in that third-party component. Probably good to report it if it's repeatable, but it may have to go upstream to the browser engine vendor.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Post Reply

Return to “iOS Deployment”