Re: Why is Base3.exe using 700+ K in windows task manager ?

From: Beth (BethStone21_at_hotmail.NOSPICEDHAM.com)
Date: 01/21/04


Date: Wed, 21 Jan 2004 16:16:15 -0000

The Half A Wannabee wrote:
> Beth wrote:
> > The Half A Wannabee wrote:
> > > Got some help at the RosAsm Board. Any comments to this newbie
code
> > ?
> > >
> > > 'Heap' in the following is redefined to mean an array of
bytes...I
> > dont even
> > > know the propper definition of a heap. But I Beth someone in
here
> > can speak
> > > volumes on the topic ;-)
> > [ snip RosAsm code ]
> >
> > You have "violated" real assembly!!
> >
> > What if someone was to take this code and use it as a "library
> > routine"??!!!
> >
> > This would hold back the "assembly rebirth" for decades to come!!!
:(
>
> LOL. Well. Remember this was my _first_ attempt at writing anything
in it.
> (not considering the WM_EraseBkGnd response code ) However. I like
your
> comments anyhow. I have allready redesigned my approach, and it will
hold,
> with some major adjustments, and added design for objects with
differing
> size. Objects/Class are here to be understood as mere CHUCKS of
memory. As
> Spasm is ment to be spesific, I dont really need a centralized
memorymanager
> at all.

Indeed; Though I was joking, this is actually a serious matter to
Rene...you're NOT being "specific" and you're risking someone learning
"HLL" by using your code as a "library routine" in posting it...

This is why I've never posted any SpAsm / RosAsm code...I really had
the intention of doing so...you know, give some help to beginners who
might be using it...but then, getting to grips with Rene's
"philosophy", I realised that it's an impossibility...it's not
allowed..."RAUCHEN VERBOTEN!" and all that kind of thing...

Indeed, you are beginning - even if only slightly - to see some of the
problem of Rene's inherent "paradox"...he insists on not seeing
it...as he complains about "HLL" and then uses "..IF" throughout the
RosAsm sources...

You must immediately _dump_ and _erase_ your "memory manager"
code...because it is clearly a "utility function" that, now you've
perfected, it would be useful and handy to "re-use" it...put it in
your "clips file"...BUT NO! If this is what you do as your first bit
of code then you will be creating your own "library" of "utility
functions"!! You are not permitted by "the philosophy(tm)" to do so!

Taboo! Verboten!

Doing this is actually - according to Rene - what is instrumental in
"holding back the assembly rebirth"...I made my reply as a joke but
Rene considers this to be deadly serious...you know that Monsanto
stuff with their GM crops? Microsoft dominance? You are, apparently,
contributing to it if you program in this way! You are condoing and
encouraging evil multi-national corporations to rape and pillage the
Earth!

Geez, don't you just feel like an evil *** doing this now that you
know about "the philosophy(tm)"?

You must re-write your memory manager _every single time_...and it
must be _specific_ to your program each time...no, in fact, you must
not "CALL" anything! That's evil "code re-use"...it is a "library
utility function", if you do that...no, you must "VirtualAlloc"
directly each and every time you want memory...hard-code the constants
into the allocation...specific! Specific! Specific!

Mind you, you could take note that Rene doesn't even follow his own
"the philosophy(tm)" in his code and tries to disguise that he
actually does allow and believe in "code re-use" and "library
functions" via the "clips file" (what is a "clips file" other than
this?)...

> For as litle code this really is, I can write a new one for the
> seperate cases.

But this "bloats" the code, doesn't it? ;)

Catching the drift of this "paradox" yet? If you use a "memory
manager" then you're going to have a smaller program...but if you
explicitly code allocation code for every "class" then it runs
faster...

Oh dear, then doesn't some "optimisation" represent a trade-off
between "size" and "speed"?

So, if we can't have any "library utility function" thing because it's
"taboo" and NOT "specific" then we must code it out for every
instance...which will "bloat" the code substantially for a large
number of objects, for very little perform gain of losing the "CALL /
RET" and passing a parameter in a register...

But, wait, isn't "specific assembly" all about _avoiding_ "bloat"?

How exactly do we remain "specific" and avoid "library code" at all
costs and, at the same time, NOT "bloat" the code because "bloat" is
also a "deadly sin" of "the philosophy(tm)"...???

Do you also kind of get the impression that Rene hasn't quite thought
this through completely?

That he's kind of just shouting "no bloat!", "no evil libraries!",
"specific assembly!" and that kind of "wishful thinking" but, in fact,
is actually demanding things that he cannot possibly _all_ fulfill at
the same time?

You know, without exception, I also demand "low-level",
"do-it-yourself", "specific coding is more optimal than generic", etc.
kind of coding...I hate Microsoft too...not a great fan of GM
crops...the "eco-warrior" of the group...I totally believe in 100% ASM
applications and though not quite Rene's Utopian "assembly rebirth", I
can see that ASM suffers unnecessarily from weak tool support...and
could certainly - as I suggest sometimes towards HLA - come to fill
the "C / ASM mix" niche with an ASM tool with improved tool
support...Rene hates this but I reckon HLA - especially if a
comparable GUI to RosAsm were to be coded for it - _better_ fulfills
that need than Rene's attempts...

He's totally well-intentioned and I don't disagree with his motives or
objectives (well, except for him wanting to blow up McDonald's...I
don't go with shooting, stabbing or blowing things up to kill people
at all...explosions on movies are cool but, like, they aren't killing
anyone so that's okay! :)...I just think that he's simply NOT got his
methods at all straight...he's not thought them through and he's
trying to "glide" the entire distance on "wishful thinking"
alone...you know, like squeezing your eyelids shut and making fists,
thinking really, really hard, trying to change the world to a better
place by just "positive thinking" _really hard_ at it for a long
time...

But, you know, you've got to _accept reality_...you've got to work
with it..."wishful thinking" alone is simply not good enough (if only
it was, eh?)...

> And come to think of it, 4K is not that bad a waste.

Depends; Is the "waste" necessary? Would "fixing" it cause too much of
a problem?

But, again, "4KB is not that bad a waste"?

Can you also feel the "creeping bloat" (something that Rene is trying
to tell us "specific" combats) coming into your program from this
specific "the philosophy(tm)"?

What next? "64KB is not that bad a waste"? "Oh, people have at least
256MB of RAM these days"? "Your program doesn't run on my machine!" /
"Oh, just buy more RAM!"...

Pay attention to someone like Gerhard or C who've pointed out that
OOP, libraries or otherwise are NOT the cause of "bloat"...it's
_ignorance_ and _sloppy design_...

After all, think about this: Isn't the point of OOP and libraries
focussed on "code re-use"? And wouldn't re-using common code - rather
than writing it out "flat" explicitly for every single instance like
this allocation stuff, which is itself happily wasting 4KB per "class"
leading to more "bloat" in what it does as well as the code itself -
help to make your code _smaller_? Wouldn't _proper use_ actually kind
of _combat_ "bloat"?

Can you kind of see that if you wanted to build a big application -
say, a web browser - where you have to be "specific" throughout and
couldn't, for example, "re-use" the same "HTML reading" code for
frames _and_ windows _and_ pop-up windows but have to copy out that
same large and hefty code multiple times...and rather sharing a DLL
which handles "HTML reading" which could also be used inside an Email
reader for HTML Emails, you've got to duplicate this code in both
applications...well, this is - amazingly, considering who we're
talking about - going to end up _more bloated_ than Microsoft
applications?

But, hey, I always believe in choice and freedom...making mistakes is
the greatest teacher of them all...carry on with this, if you
like...just don't say I didn't warn you...but I guarantee you - with
confidence verging on arrogance - whatever Rene's "the philosophy(tm)"
tells you to do, I - or Randy - will always be able to show you
_better_...

As I say, Rene kind of plays to the things people like to hear: "I
will bring about the assembly rebirth!", "no specific assembly
philosophical and ethical software will ever be bloated!", "strategy
optimisation will rid the world of evil!", etc....and Randy does tend
to have a bit of a "posh talking teacher" edge to him that, like, Rene
sounds "less boring" than Randy (who, actually, is telling it like it
is...it's just that "how it is" isn't particularly non-boring...good
data structure design and decompiler theory _is_ terminally
boring...heck, even Randy confess to yawning his way through to an
extent...and my ***-up with the "Big Oh notation" _is_, as Randy
nailed perfectly, exactly because I wasn't really paying complete
attention in those lessons, I confess ;)...

But, no, really...lest this be taken as "propoganda", _stick with
RosAsm_...it's not that bad because as long as you've got access to
the machine instructions and some sort of control over your data (I
still think it's "not good enough" in RosAsm but it's "usable",
certainly)...actually find out how far you can go with it...it's NOT
wasted time because, despite the big fuss about "syntax", that's a
fairly trivial concern...and what you learn with RosAsm won't be
wasted...and then when you've hit the limits and are confused by how
Rene's "the philosophy(tm)" _doesn't_ quite do what he promises, go
over to NASM...yeah, if you like, NEVER use HLA ever...people wrote
perfectly good applications before HLA and they learnt assembly well
(after all, by definition, Randy must have picked up his expertise
"elsewhere", right? And me and others around here too because we're
"B.H." (Before HLA) dinosaurs :)...

I get no "commission" from pointing out that HLA is better...I'm just
concern to seeing it be given a bad reputation when it's NOT deserving
AT ALL...as has always been the case on this group, I post to
_help_...that's my priority...anything else is just some nice "bonus
points", I suppose...

> Its per class.

"Class"? As in: "window class" or as in "OOP class"? You know "the
philosophy(tm)" isn't happy with you using anything OOP? It's "bloat",
apparently...

Of course, how Rene resolves this with using _COM-based_ DirectX,
which is based on OOP...or using "window classes" in Window which is
an object-like methodology...or how we resolve an awful lot of OOP
that RosAsm, by necessity, must work with?

Plus, of course, OOP is NOT defined by a "class" keyword...check out
Booch and his OOP jargon colleagues and the definition of an "object"
tends be along the lines of being a set of related "services" which
share "persistent data"...are we entirely sure we're NOT actually
doing OOP without even realising?

You know that "HWND" parameter in the window class? Doesn't it kind of
"identify" which "instance" of the "window class" we've got for a
common "service" across all windows of that "class"? Isn't that "class
background brush" kind of "persistent data" between multiple
"instances" of our "class"? Isn't this jargon kind of sounding like
OOP jargon?

You know what that first "HWND" parameter is, don't you? It's a "this"
pointer...

Have you ever _examined_ your "HINSTANCE" from "GetModuleHandleA"? And
then compared it to the load address of your module? Why, there's a
coincidence, they are exactly the same! Smacking of a type of "this"
pointer again, yet?

Rene doesn't use OOP because he doesn't really know what it is...at
least, not _properly_...he probably doesn't realise that he's
_surrounded_ by it, even in the most unlikely places...he's probably
written some OOP unwittingly (I must have a closer look over that
RosAsm source code to see what I can find, eh? ;)...

> I will honestly not need more than about 300 "Class" -like objects
in
> the framework I am building and that will waste = 1200K maximum.

1.2MB of RAM? "Acceptable"? NOT IN MY BOOK IT'S NOT!

Just do us a quick kind of favour, yeah? Temporarily _ignore_ "the
philosophy(tm)" and re-calculate how much it would be if you re-coded
with a "memory manager" that properly squeezes memory together for
"byte perfect" NO wastage at all...

Then, once re-calculated, tell me what the size of your level 1 and
level 2 caches, your CPU - memory bus bandwidth and your virtual
memory / physical RAM figures...plus, you're using XP, yeah? Read off
the "system cache" figure and how many tens of MBs Explorer's stolen
for its "caches" and "buffers"...how many "system tray" utilities have
you got running and what's their usage like?

Starting to get the rough point yet?

Whereas, say these "objects" take up, say, 300 bytes...squeezed
together: 300 * 300 = about 87KB...1.2MB versus 87KB?

What do you think your cache memory will prefer? Are you totally sure
that laying it out "flat" like this, in a "specific" way, _does_
automatically mean you're optimising for "speed"? Because, clearly, it
_AIN'T_ improving things on the "size" front one bit...

I've worked in 64KB and 512KB _total RAM_ before and 1.2MB is kind of
an _offensive waste_ of RAM to me...you'd be buggered with that
attitude on a PDA where RAM _is_ the "hard disk"...

I say it again, Rene has become his own worst enemy...handing out a
"philosophy" that gets people "bloating" like pufferfish in all
directions? Sounds _exactly_ like the sheer crap I've loathed
tolerating from Microsoft for decades...

> Abit cruel,
> but considering that windows allready waste as much, and that my
DELPHI
> version of the library uses about 12 _megs_ of ram for the same
> functionality ( = 10x) , I consider 1200K to be acceptable.

In my opinion, though I'm happy to see people disagree, the _WRONG_
attitude...

Considering Windows already wastes too much, surely we want to _keep
it down_ as far as possible?

Remember, the cache on your CPU doesn't "expand" like virtual memory d
oes...your physical RAM doesn't either (well, it's NOT recommended
that you try to install more while the machine is actually
running...it probably wouldn't work, anyway...RAM isn't a "plug and
play" device ;)...and when you do "expand" into virtual memory, your
memory accesses are going effectively _via disk_...

I Hope you've deleted your default "page file", defragged and then
created a custom sized "page file" with the _same_ "minimum" and
"maximum" figures that it's pointless to exceed about 3 times your
physical RAM...page file fragmentation, you see...it may be pretending
to be memory but it's still a disk file...it fragments (often,
horribly)...if you "expand" and "contract" too often, expect a
"patchwork quilty" of "unmoveable" in the defrag view of your hard
drive contents...hence, by deleting and re-creating a fixed size "page
file", you get one big contiguous file with no fragmentation...if
you've never done this and have had your machine for a while, try it
and discover less "thrashing" and better performance when you start
"overloading" memory...

Plus, you just swore terrible curse words...a "library" using a
"memory manager" for "OOP"? The veins on Rene's forehead are
pulsing...you have spoken the "taboo", he will unleash his wrath on
you if you're not careful...watch out, as well, because Rene _ejects_
people out of his "club" who "clearly do not understand" / "I would
not want users who do not understand"...

> For the
> HandleList, I will do a complety diffrent approach. And the speed
will be
> unparallelled to Delphi, even if I do it in beginner like style,
just
> because it is spesific.

Yeah, to a degree...depends what you mean by "specific"...shame Rene
doesn't help beginners a little more, as from what I've heard him say,
some of the things you've been saying I'm not completely sure would be
_his_ "specific"...

But _algorithm_ is king...your speed is, in _majority_, decided by how
you approach a problem...if that's badly wrong, ignore everything
else...it's immaterial because you've messed big before you've even
started with anything "ASM"...

Depending on what you mean by "beginner-like" and "specific", you
_could_ end up shocked by it potentially being _worse_ or not much
better..."naive" implementations in ASM can usually have their arse
kicked hard by _good_ implementations in C or Pascal...

Mind you, if the original Delphi stuff was "beginner-like" too then,
sure, you'll win...but that's because _algorithm_ is
king...implementation language is "prince" to that king, if you catch
my drift...

> I have an advantage in that I have allready done
> this framework once, in pascal so it is now much easier to see some
> improvements. I will post back working code when I get there.

Well, you really shouldn't, if you follow Rene's "the
philosophy(tm)"...

But if you're happy to ignore that completely...then, sure, the rest
of us Love to pour over posted code...actually, see if you could tempt
Frank Kotler to look at it or something...he's like an "emergency car
mechanic" on the group and Loves to help along someone "tweak" their
code...the syntax won't matter...he calls himself a "NASM bigot" but
has dealt with code from every assembler...well, except RosAsm, but
that's kind of because of Rene's insistance that "library code" is
"taboo"...

Funny, really...Rene moans about everyone on the group but, hey, he
stays hanging around here...granted, that's partly because he got
_kicked out_ of a whole bunch of other forums for pissing them off in
a big way...and, like, he's "safe" here because we're totally
unmoderated Usenet that no-one can be "forcably ejected" by big
bouncers...

> PS : My style is not like Spams/RosAsm. Not as readable. I have not
yet
> gotten hang of the macros. I only used three sofar, the AlignOn
macro and
> the push / pop macros. But I guess, after some time I will feel a
need for
> them. BTW : I think you would still have NO problem at understanding
what
> the code is trying to do.

No, I wouldn't have a problem...in fact, if you actually want me to
give it a bit of a "look over" to see if I can suggest anything, I'd
be glad to do so...I only didn't offer and do originally because I
wasn't sure if it was a valid "please help me with my RosAsm code" or
just some kind of "look, RosAsm is great" protest post...pardon if I
jumped to the wrong conclusion there...

> Thanks you for input anyhow.

Oh, don't worry...you _get_ my input, whether you like it or
not...hehehe...just kidding, just kidding ;)

Beth :)