"OVER 9000!" Object IDs

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nlexa
Posts: 26
Joined: Fri Aug 05, 2011 2:34 am

"OVER 9000!" Object IDs

Post by nlexa » Mon Feb 10, 2014 4:28 am

I have a stack that
1. Creates many objects - to populate a screen with controls
2. Deletes them - to clear the screen for repopulation.
For all objects, the ID is guaranteed to be unique within a stack. IDs are not reused if the object is deleted.
At the moment my objects have IDs of 91000.
I'm concerned that over time the IDs will get larger and larger because the IDs are not reused.
Will this lead to any appreciable loss in speed of the program?

Lets say that my program runs all day for a year. It refreshes the screen once a minute deleting the old objects and creating 200 new objects.
200 * 60 * 24 * 365 = 105,120,000

I guess it would take 50 year of running continuously for the ID numbers to be so great that they take up more than 1 byte on a 32bit computer.

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

Re: "OVER 9000!" Object IDs

Post by FourthWorld » Mon Feb 10, 2014 4:33 am

IDs in LiveCode are indeed 32-bit values, so the upper end of the range is just under 4.3 billion - should take a very long time to reach that.

If one had a serious concern, rather than creating and disposing of objects it would save IDs (and possibly be more effecient in other areas) to simply hide and show controls as needed, reusing existing ones as you go.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: "OVER 9000!" Object IDs

Post by dunbarx » Mon Feb 10, 2014 6:26 am

Hi.

I am with Richard on this.

If you are currently creating controls, it is likely you are also setting certain properties at creation time, such as, say, name, rect and loc. If you had a bunch of these ready-made, you might similarly set those properties (and perhaps have to manage fewer of them), and just hide and show as many as you need at any particular time. I bet this will require less management than you are supporting now.

Craig Newman

Post Reply