[comp.sys.mac.programmer] Max. no. of code segments

thinfilm@uxh.cso.uiuc.edu (04/21/89)

  What is the largest number of segments allowed in an application on the
mac and what rules should one work by for this.  I am specifically talking
about code segments here.  I would like to partition the code into logical
elements to optimize memory use.  If I did so each segment would by about
15-25K and there would be on the order of 150 of them (yes this is a lot of
code).  Is this liable to break anything or can the mac handle it.  Which
tn should be looked at etc.  Thanks for any help you can offer.
				thinfilm@uxh.cso.uiuc.edu

keith@Apple.COM (Keith Rollin) (04/23/89)

In article <53100005@uxh.cso.uiuc.edu> thinfilm@uxh.cso.uiuc.edu writes:
>
>  What is the largest number of segments allowed in an application on the
>mac and what rules should one work by for this.  I am specifically talking
>about code segments here.  I would like to partition the code into logical
>elements to optimize memory use.  If I did so each segment would by about
>15-25K and there would be on the order of 150 of them (yes this is a lot of
>code).  Is this liable to break anything or can the mac handle it.  Which
>tn should be looked at etc.  Thanks for any help you can offer.
>				thinfilm@uxh.cso.uiuc.edu

A 3 Meg program!!! Wow!!!

There shouldn't be any problem with this number of code segments, per se. 
However, this is a limit placed on the number of inter-segments calls you can
make. For more information on this, see Technote #220: Segment Loader Limit-
ations.

------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

oster@dewey.soe.berkeley.edu (David Phillip Oster) (04/26/89)

In article <53100005@uxh.cso.uiuc.edu> thinfilm@uxh.cso.uiuc.edu writes:
>  What is the largest number of segments allowed in an application on the
>mac and what rules should one work by for this. 
Since a resource map can only have about 2000 entries, you can only have
2000 code segements in one file.

The global segment jump table is 32k bytes long, so you can only have
roughly 4k jump insturctions in it: that is, you can only have 4k globally
visible procedures. Both C (the "static" keyword) and pascal (nested
procedures) let you define procedures that won't appear in the global
segment tables.

Note: the reosource manager uses linear search, so if you have 2k code
segments, any procedure cal that causes a LoadSegement() will likely be slow.

--- David Phillip Oster            --"When we replace the mouse with a pen,
Arpa: oster@dewey.soe.berkeley.edu --3 button mouse fans will need saxophone
Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu --lessons." - Gasee