skywalk wrote:
I use #PB_Any almost always, but don't understand the difference between object numbers assigned automatically vs those assigned by a user constant?
As Trond pointed out correctly, #PB_Any values are actually pointers that store the necessary information about the gadgets, the OS handle for example.
skywalk wrote:
Why is more memory consumed when a user assigns an arbitrary constant of 10000 for a gadget?
I just said that one post above yours. PB allocates an array with (at least) the size of the largest gadget number.
If you're creating a gadget with the ID 10'000, PB creates an array with the size of 10'000 fields and stores the information about
that gadget at position 10'000 in order to directly access them. All the other elements are empty until you create gadgets with those numbers.
(If that's not what PB does, please tell me).
skywalk wrote:
Yet, the #PB_Any object number is just as high?
Couldn't the compiler just sort and reassign constants to eliminate gaps?
Sure the gadget list could be optimized for size but that would prevent PB from directly accessing the information
via the array index and thus slow down the process of acquiring that information since the correct number has to be searched.
Although I think that would be a more efficient way...but then again you could just use #PB_Any which is way more flexible anyway.
skywalk wrote:
I assume the use of #PB_Any is not wasting memory.
Nope. If you use #PB_Any, PB can access the information directly since it is a pointer.
