File foot-print in memory. Variables vs literals.

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

File foot-print in memory. Variables vs literals.

#1 Post by sunburnt »

A run file made two ways:

With variables:
/$appPath/$file ; /$callPath/$caller

Or with literals:
/11111/22222/33333/fileName ; /aaa/bbb/ccc/callingApp

The variables in the first one hold the same strings as the second one.

The file stays in memory while the app. runs, and exits when it does.
I think that the memory foot-print is the same for both.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#2 Post by technosaurus »

using the string directly oncd should be slightly smaller, but ...

if you plan to use it more than once - use a variable
if you dont want to have incomprehensible "magic numbers" - use a variable
if you may eventually use it more than once - use a variable
if it may change - use a variable (much easier to change it in one place)
if the string already exists in a variable - use a variable (unless an outside source might change it and bork your script)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

Hey technosaurus; I figured they were close to the same size in memory.

This is to go into a Squash file app. to run it`s exec. and stays in memory.
So I want it to be as small as possible being as it "hangs" in memory.

When the app. ends, this script calls the mount script to unmount the Squash.
Variable script:

Code: Select all

$1/bin/Exec ; $2 -x $1 &
Usage: /Path/SqMountPt/run /Path/SqMountPt $0 &
To use the mount script: app.sq_run /Path/SqAppFile
Literal script:

Code: Select all

/Path/SqMountPt/bin/Exec ; app.sq_run -x /Path/SqMountPt &
The mount points are always different, the path to them is always the same.
And ultimately, quite often apps. have their exec. files in different places.
The run script is generated just before the Squash app. file is made.
.

Post Reply