Strings and memory management - Page 2


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 37

Thread: Strings and memory management

  1. #16
    Michael \(michka\) Kaplan Guest

    Re: Strings and memory management

    I think you would be amazed how often VB converts those strings, anyway....

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "Oren" <CompuMight@erols.com> wrote in message
    news:39674bd7$1@news.devx.com...
    > First of all, usually strings have to do with UI, the user is the slowest

    part of a computer, ), therefore if you must do "a" + "
    > b" + "c", they most likely won't notice the less than a milisecond

    difference, )
    >
    > Second of all, if you create an AX dll there is no unicode/ansi

    conversion. You can cheat the conversion via type libraries.
    >
    >
    > Oren
    >
    >




  2. #17
    Michael \(michka\) Kaplan Guest

    Re: Strings and memory management

    I think you would be amazed how often VB converts those strings, anyway....

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "Oren" <CompuMight@erols.com> wrote in message
    news:39674bd7$1@news.devx.com...
    > First of all, usually strings have to do with UI, the user is the slowest

    part of a computer, ), therefore if you must do "a" + "
    > b" + "c", they most likely won't notice the less than a milisecond

    difference, )
    >
    > Second of all, if you create an AX dll there is no unicode/ansi

    conversion. You can cheat the conversion via type libraries.
    >
    >
    > Oren
    >
    >




  3. #18
    Oren Guest

    Re: Strings and memory management

    I know how many times, I've done many a dumps, )

    Oren



  4. #19
    Oren Guest

    Re: Strings and memory management

    I know how many times, I've done many a dumps, )

    Oren



  5. #20
    Jonathan Wood Guest

    Re: Strings and memory management

    Brian,

    > I program in C++ as well as VB and considered writing a function to do

    this
    > in C++.
    > I envisioned passing Unicode strings to C++ and having to convert them to
    > ANSI and then back
    > again as well as having to copy them into a C++ string before casting it
    > into a BSTR and passing
    > it back. Alternatively, I suppose I could use byte arrays as strings and
    > the API copyMemory into a
    > fixed length string after determining the total length of the final

    string.

    Huh? If you are trying to optmize this process, why would you convert
    Unicode to ANSI and then back?

    If you use a typelib, VB can pass the Unicode strings unchanged. I would
    think you'd then want to work with and return Unicode strings.

    Also, be careful with CopyMemory (RtlMoveMemory) because it will convert the
    strings to ANSI and back unless you use something like StrPtr to pass the
    address of the Unicode data.

    > I suppose the slowest step would probably be writing
    > these strings to file rather than
    > memory management of even large strings.


    Amen to that!

    Jonathan




  6. #21
    Jonathan Wood Guest

    Re: Strings and memory management

    Brian,

    > I program in C++ as well as VB and considered writing a function to do

    this
    > in C++.
    > I envisioned passing Unicode strings to C++ and having to convert them to
    > ANSI and then back
    > again as well as having to copy them into a C++ string before casting it
    > into a BSTR and passing
    > it back. Alternatively, I suppose I could use byte arrays as strings and
    > the API copyMemory into a
    > fixed length string after determining the total length of the final

    string.

    Huh? If you are trying to optmize this process, why would you convert
    Unicode to ANSI and then back?

    If you use a typelib, VB can pass the Unicode strings unchanged. I would
    think you'd then want to work with and return Unicode strings.

    Also, be careful with CopyMemory (RtlMoveMemory) because it will convert the
    strings to ANSI and back unless you use something like StrPtr to pass the
    address of the Unicode data.

    > I suppose the slowest step would probably be writing
    > these strings to file rather than
    > memory management of even large strings.


    Amen to that!

    Jonathan




  7. #22
    Jonathan Wood Guest

    Re: Strings and memory management

    Oren,

    > [...] I've done many a dumps, )


    Please keep your bathroom habits private.

    Jonathan




  8. #23
    Jonathan Wood Guest

    Re: Strings and memory management

    Oren,

    > [...] I've done many a dumps, )


    Please keep your bathroom habits private.

    Jonathan




  9. #24
    Brian Leung Guest

    Re: Strings and memory management


    Hi Oren,

    Sounds like you're looking at what VB does behind the scenes.
    I don't know how to do this, but would like to find out.
    Can you point me to any sites or books?

    Thanks,

    Brian


    "Oren" <CompuMight@erols.com> wrote:
    >I know how many times, I've done many a dumps, )
    >
    > Oren
    >
    >



  10. #25
    Brian Leung Guest

    Re: Strings and memory management


    Hi Oren,

    Sounds like you're looking at what VB does behind the scenes.
    I don't know how to do this, but would like to find out.
    Can you point me to any sites or books?

    Thanks,

    Brian


    "Oren" <CompuMight@erols.com> wrote:
    >I know how many times, I've done many a dumps, )
    >
    > Oren
    >
    >



  11. #26
    Brian Leung Guest

    Re: Strings and memory management


    Hi Jonathan,
    >
    >Huh? If you are trying to optmize this process, why would you convert
    >Unicode to ANSI and then back?


    I wouldn't want to, which is why I didn't like this idea.

    >
    >If you use a typelib, VB can pass the Unicode strings unchanged. I would
    >think you'd then want to work with and return Unicode strings.


    Yes. that sounds like a better option. I should probably learn
    how to do that, but until now have only been programming with
    standard C++ features.

    >
    >Also, be careful with CopyMemory (RtlMoveMemory) because it will convert

    the
    >strings to ANSI and back unless you use something like StrPtr to pass the
    >address of the Unicode data.


    I hadn't considered that.

    >
    >> I suppose the slowest step would probably be writing
    >> these strings to file rather than
    >> memory management of even large strings.

    >
    >Amen to that!


    Any suggestions on how best to write to file? i.e., is it
    better to concatenate a large string and write that rather than
    writing separate small string?? Is there a optimal string
    length to write at a time?

    Cheers,

    Brian
    >
    >Jonathan
    >
    >
    >



  12. #27
    Brian Leung Guest

    Re: Strings and memory management


    Hi Jonathan,
    >
    >Huh? If you are trying to optmize this process, why would you convert
    >Unicode to ANSI and then back?


    I wouldn't want to, which is why I didn't like this idea.

    >
    >If you use a typelib, VB can pass the Unicode strings unchanged. I would
    >think you'd then want to work with and return Unicode strings.


    Yes. that sounds like a better option. I should probably learn
    how to do that, but until now have only been programming with
    standard C++ features.

    >
    >Also, be careful with CopyMemory (RtlMoveMemory) because it will convert

    the
    >strings to ANSI and back unless you use something like StrPtr to pass the
    >address of the Unicode data.


    I hadn't considered that.

    >
    >> I suppose the slowest step would probably be writing
    >> these strings to file rather than
    >> memory management of even large strings.

    >
    >Amen to that!


    Any suggestions on how best to write to file? i.e., is it
    better to concatenate a large string and write that rather than
    writing separate small string?? Is there a optimal string
    length to write at a time?

    Cheers,

    Brian
    >
    >Jonathan
    >
    >
    >



  13. #28
    Oren Guest

    Re: Strings and memory management

    click the "create symbolic debug info" in the compile options and do a standard debug, VC++ is perfectly fine for this.

    Oren

    p.s. Since you can't exactly call int's from your vb code, <sob>, ), you can use the DebugBreak api call to force the default
    system debugger to be called



  14. #29
    Oren Guest

    Re: Strings and memory management

    click the "create symbolic debug info" in the compile options and do a standard debug, VC++ is perfectly fine for this.

    Oren

    p.s. Since you can't exactly call int's from your vb code, <sob>, ), you can use the DebugBreak api call to force the default
    system debugger to be called



  15. #30
    Jonathan Wood Guest

    Re: Strings and memory management

    Brian,

    > Yes. that sounds like a better option. I should probably learn
    > how to do that, but until now have only been programming with
    > standard C++ features.


    Like I said, we do this type of thing all the type for ourselves and various
    clients.

    > Any suggestions on how best to write to file? i.e., is it
    > better to concatenate a large string and write that rather than
    > writing separate small string?? Is there a optimal string
    > length to write at a time?


    Disk access is always slow. For the most part, any code that must be as fast
    as possible will not include disk access. There are times where the data is
    organized in such a way that it can be written in a large chunk without a
    bunch of conversions. But for many cases, the benefits do not justify
    worrying about it.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center