Re: Listing apps in launch order
Re: Listing apps in launch order
- Subject: Re: Listing apps in launch order
- From: John W Baxter <email@hidden>
- Date: Sun, 28 Jan 2001 17:13:50 -0800
At 13:33 -0500 1/28/01, Bill Cheeseman wrote:
>
on 1/28/01 11:57 AM, Matthew Fischer at email@hidden wrote:
>
>
> It's my understanding (feel free to correct me if I'm wrong) that if you
>
>don't
>
> quit applications in the reverse order of the order they were launched that
>
> you don't get back all the memory they have allocated to them. Sometimes
>
>if I
>
> have a bunch of things running, I can't remember what order they were
>
>launched
>
> in.
>
>
>
> How would I go about using Applescript to get a list of my currently running
>
> applications in the order they were launched?
>
>
It isn't that you don't get all your memory back (except in the case of some
>
ill-behaved apps). The problem is that your memory will become fragmented,
>
with two or more smaller free space areas, instead of one larger area. This
>
should only hurt if you try thereafter to launch an application that needs a
>
larger contiguous free space area than any of those you have left, or if you
>
thereafter launch several smaller apps that do fit but which then leave a
>
few fragments of free space that are too small individually to let any
>
application launch.
>
>
In a typical user's experience (use very few apps, shut down every night),
>
this problem will rarely if ever crop up.
>
>
Caveat. The foregoing is based on info I acquired a very long time ago. It's
>
possible that memory management is much smarter now in the classic Mac OS.
>
The problem does not arise at all in Mac OS X.
>
>
I'm not aware of any simple way you can use AppleScript to resolve this
>
issue. There have been several utilities over the years that show you a
>
graphical representation of your current memory space and usage, but I'm not
>
aware that any of them is scriptable in a useful way. A 1998 utility,
>
ProcessWatcher 3.2, is scriptable, but the dictionary doesn't suggest it
>
will tell you what you want to know (the application itself doesn't, either
>
-- it just lists all running processes), and I got errors trying to use the
>
AppleScript commands it does implement. I normally use Memory Mapper 1.5,
>
another 1998 utility, which has a nice graphical representation of your
>
memory map that shows you what you want to know -- but it isn't scriptable.
>
>
You could write a stay-open AppleScript application, with an idle handler
>
that fires every few seconds, to run in the background at all times. It
>
could be written to notice when every new process launches and when it
>
quits, keeping a constantly-updated list of the order in which current
>
processes were launched. With some careful arithmetic, you could probably
>
even record the amount of memory each uses and track the number and size of
>
your free space fragments. But it would be a lot of work for a very small
>
payoff.
>
If...
all the apps of interest opened after any you want to keep open; and
you want to close all the apps of interest; and
none of the apps you want to keep open allocate lots of temporary memory
while you're closing apps, and none of them did that while you were opening
apps, or all of the apps with temporary memory are well-behaved and don't
lock handles in temporary memory and leave them locked when they aren't
active, then it shouldn't matter what order you close the apps in...all the
memory will be freed up and available once the last app of the group is
closed.
Temporary memory is where BBEdit keeps the text of the documents you have
open, IE keeps its stash of pages, MPW writes lots of its temporary
information, and so on.
If you DO want to know launch order and/or memory address, it isn't hard in
C (or whatever) [sorry about the line wrap]:
Sunday, January 28, 2001 at 16:55:26
Your machine was started on Sunday, January 28, 2001 at 15:00:22
Name Sig Type Location Size Free Mem
Launched Ticks used
Control Strip Extension sdev appe 0x05CFA6C0 0x00038800 0x0001BA70
15:02:27 1/28/01 53848
FBC Indexing Scheduler fbcb appe 0x05CC0200 0x0001D000 0x00007A10
15:02:27 1/28/01 23
HP Background HPBG appe 0x05C26140 0x00028800 0x00016DF0
15:02:27 1/28/01 4677
Time Synchronizer tims appe 0x05C028E0 0x00023000 0x0000AFC0
15:02:28 1/28/01 91
Application Switcher apsw appe 0x05C979D0 0x00028400 0x0000F0D0
15:04:30 1/28/01 1632
Folder Actions ssrv appe 0x05A79520 0x00070800 0x00054250
15:04:30 1/28/01 2985
Finder MACS FNDR 0x05976910 0x00102C00 0x00279E60
15:04:32 1/28/01 19857
Eudora CSOm APPL 0x056E8100 0x0028E800 0x000C8D50
15:07:09 1/28/01 271301
Script Debugger asDB APPL 0x051E88F0 0x004FF800 0x00395760
16:44:53 1/28/01 22490
Process Lister ???? APPL 0x0511B0D0 0x0007D800 0x0005D430
16:55:25 1/28/01 0
Done.
The Process Manager gives up the information rather easily...the Launched
column is the time at which the application/FBA/whatever was launched (it
can easily be returned as an AppleScript date (type 'ldt ')). The location
is the address of one end or the other of the application...lowest address
I *think*.
The program which made that list is a simple C program (for an older
Codewarrior)...it displays what it learns from Process Manager about each
process. There are much better such programs around to do the job. A
scriptable one would be nice, and could exist. (It's the application which
showed me that Application Switcher leaks memory in every Mac OS version
from when it appeared through 9.0.4...this leak is fixed in 9.1.)
--John
--
John Baxter email@hidden Port Ludlow, WA, USA