Results 1 to 6 of 6

Thread: Data Types

  1. #1

    Thread Starter
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444

    Data Types

    Is using As String worse for memory versus As String *4 (for fixed length)? Question is if I know the length of the string, should I use fixed length or variable length?

    I kind of took for granted that VB acomodates for the changes certain string variable undergoes. For example assigning "longlonglong string" would allocate certain number of bytes, but re-assigning the same variable with "short str" would null it in memory and new number of bytes would be allocated.

    Can someone comment on this please?

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Fixed sized strings are even slower than the variable length strings, so you should use it only in the cases you have to. One other noticeable thing is that VB.NET doesn't support fixed sized strings. And I think fixed strings might take more memory as well, I'm not 100% sure about this. I think I sometime read about some extra overhead.

  3. #3
    i think fixed lenght strings are 10% bytes more

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794
    Originally posted by nareth
    i think fixed lenght strings are 10% bytes more
    Maybe 10 bytes more, but 10% more ??? that would be way too much... and 10% of what ?

  5. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Some interesting information: http://www.devx.com/vb2themax/Tip/18269

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Some more interesting information! It is over two times faster to use fixed length string than Left$! So if you ever need to parse a same number of characters using Left$, you might want to use a fixed length string instead, if it is even a little time critical.

    My results showed 600 ms vs 1300 ms just to parse two characters. Though, the speed difference gets more equal when you get to real big strings, but fixed length strings are still faster. I don't know if it can get into point until fixed length strings are no good compared to Left$.

    Now I can seriously consider getting sleep! These speed tests of mine are getting insane...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width