Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using object.TAG as a variable

Status
Not open for further replies.

TRYP

Programmer
Jun 20, 2000
136
US
is ram saved (regardless of the amount) if a value is stored in an objects TAG instead of creating a variable ??<br>-------tryp
 
I'm not heavy into the internals of VB, but here is my take.&nbsp;&nbsp;The tag property is a string, so an object always has the overhead of an empty string even when the tag is empty.&nbsp;&nbsp;This is a pointer which is a long integer (4 bytes).&nbsp;&nbsp;The pointer contains the value zero when the string (tag) has not been given a value.<br><br>On the other hand, if a string is created in code to hold the data, it will be the size of the string, plus the overhead (the 4 byte pointer), so it would seem that using the tag would save 4 bytes for the pointer because those bytes are already allocated when the object is created.<br><br>Since VB holds the length of strings, rather than using a null terminator as in C, there is probably more overhead for that as well (probably 4 more bytes).&nbsp;&nbsp;Again, this space is probably already allocated in the object and just wasted if tag is not used, so it may save 8 bytes or more to use the tag.<br><br>This is all based on best guess.&nbsp;&nbsp;Any other ideas?
 
thanx i know 8 bytes isnt gunna make a machine start sprinting but if programmers start thinking like they did 30 years ago about waranting every last byte of RAM usage i can almost guarantee a major step-up in alaround performance.

i had this teacher who used to tell us avout the punch cards he worked with and how every last bit was used and maximized to its full potential. since system resources were at a premium.

programmers today are at such an ease of use of big data types
that saving a byte or a megabytle is too much of a hassle ahh!
 
TRYP,

I am one of those who started with the IBM punch cards. Believe me we didn't do all that work to squeeze the bytes from any noble perspective. It was just plain [red]NECSSSARY[/red]. Even some of the first generation of IBM PC with 8K (bytes) of memory and the 4.77 MHz clocks were a luxury compared to some of my early programming environments.

Yes, I have agonized over how to save 8 bytes of memory - even to the extent of re-writing assebly language code to save the instruction space. Als, many other trails and tribulations over both memory and execution speed. But NEVER because &quot;... it just seemed right ...&quot;.

Try to keep some perspective here, we did it either because we HAD to (from the machine resources perspective) or the cost of that hardware was a LOT more than our salary! Try to compute the &quot;cost&quot; of the &quot;8 Bytes&quot; of memory - in your computer today, and convert it to how long it takes you to expend the same $$$ using just your salary. If you can honestly say it is worth it, I want a job there!!!!!!!

MichaelRed
There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top