• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: TextEdit oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TextEdit oddity


  • Subject: Re: TextEdit oddity
  • From: Ron Hunsinger <email@hidden>
  • Date: Tue, 20 May 2014 18:02:54 -0700

On May 20, 2014, at 7:48 AM, koenig.yvan <email@hidden> wrote:
> If the file is smaller than 2^16 everything works well.

AHA!!!

You've bumped up against the maximum size of an AppleEvent record.

Applications communicate by sending IPC messages to each other. That's the underlying technology that AppleEvents are built on. Every AppleEvent must fit in an IPC message.

The maximum size of an IPC message is known as ARG_MAX. It's compiled into the kernel of the OS, and cannot be changed. You can get the value of ARG_MAX by entering the shell command:

	sysctl kern.argmax

When you do, you'll see that the limit is currently (at least in Tiger thru Mavericks) fixed at 262144, aka 2^18 bytes. That's enough for 2^17 UTF-16 characters, except that some space will also be used for overhead.

This hard limit is also the reason for the xargs shell command. When the shell (or any other process) runs a command, it must pass to it all the command's arguments, plus a copy of the current environment. All of this needs to fit in a single IPC message.

If you want to use AppleScript to modify very large documents, you're better off sending the application smallish commands that tell the app what to do to the document. Let the app do the heavy lifting internally. Don't ask for the details.

If you must process all the text yourself, don't ask the app to give you all of it in a single command, nor try to pass back the entire document in one command. Break the work into chewable pieces. Not that AppleScript is going to be able to efficiently deal with large amounts of anything, no matter how you slice it.

-Ron Hunsinger
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


  • Follow-Ups:
    • Re: TextEdit oddity
      • From: Shane Stanley <email@hidden>
References: 
 >TextEdit oddity (From: "koenig.yvan" <email@hidden>)
 >Re: TextEdit oddity (From: Shane Stanley <email@hidden>)
 >Re: TextEdit oddity (From: "koenig.yvan" <email@hidden>)
 >Re: TextEdit oddity (From: Deivy Petrescu <email@hidden>)
 >Re: TextEdit oddity (From: "koenig.yvan" <email@hidden>)

  • Prev by Date: Re: TextEdit oddity
  • Next by Date: Re: TextEdit oddity
  • Previous by thread: Re: TextEdit oddity
  • Next by thread: Re: TextEdit oddity
  • Index(es):
    • Date
    • Thread