Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Issue with SysFreeString...

Issue with SysFreeString...

Scheduled Pinned Locked Moved COM
comperformancehelptutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    ganesa moorthy
    wrote on last edited by
    #1

    Hi, I am having a COM Component and i am accessing the com using VB client. In Com function i am using SysFreeString, i am calling a function inside COM DLL by passing a string argument from vbclient. After usage i am calling SysFreeString inside the com function. The above mentioned functionality works on several machines and fails(VB client crashes) in one machine. I removed the SysFreeString function call from the failing machine, and now it is fine. Can anyone tell why this happens so strangely ? Anyway we need to call SysFreeString to free up the memory. Kindly guide me! :( Advanced Thanks, Ganesha

    Thanks a lot

    J G 2 Replies Last reply
    0
    • G ganesa moorthy

      Hi, I am having a COM Component and i am accessing the com using VB client. In Com function i am using SysFreeString, i am calling a function inside COM DLL by passing a string argument from vbclient. After usage i am calling SysFreeString inside the com function. The above mentioned functionality works on several machines and fails(VB client crashes) in one machine. I removed the SysFreeString function call from the failing machine, and now it is fine. Can anyone tell why this happens so strangely ? Anyway we need to call SysFreeString to free up the memory. Kindly guide me! :( Advanced Thanks, Ganesha

      Thanks a lot

      J Offline
      J Offline
      Jonathan Davies
      wrote on last edited by
      #2

      Hi, I can't say why one machine behaves differently, in fact I would say if you can fix the code so it works on all machines you don't need to know. All my VB -> COM was done in Visual Studio 6 and used IDL rather than attribute based which yours may be but the issues should be the same. What IDL attributes are applied to the string being passed, an [in] or [in,out] or possible [retval]? As you are freeing the string in the .dll, I'm assuming its an [in]?

      G 1 Reply Last reply
      0
      • J Jonathan Davies

        Hi, I can't say why one machine behaves differently, in fact I would say if you can fix the code so it works on all machines you don't need to know. All my VB -> COM was done in Visual Studio 6 and used IDL rather than attribute based which yours may be but the issues should be the same. What IDL attributes are applied to the string being passed, an [in] or [in,out] or possible [retval]? As you are freeing the string in the .dll, I'm assuming its an [in]?

        G Offline
        G Offline
        ganesa moorthy
        wrote on last edited by
        #3

        Hi, [in], [out], and sometime [out,retval] Advanced Thanks!!!!

        Thanks a lot

        J 1 Reply Last reply
        0
        • G ganesa moorthy

          Hi, [in], [out], and sometime [out,retval] Advanced Thanks!!!!

          Thanks a lot

          J Offline
          J Offline
          Jonathan Davies
          wrote on last edited by
          #4

          That seems right, I think VB passes strings by reference so it has to be [in,out]. As there is an out] part, VB expects a string to be passed back (out) and is probably deleting this according to some garbage collections algorithm - but you've already done it in the dll. I think not deleting it in the .dll is OK here - you would only do this if it were an [in]. You could delete it in the dll but only is you then assign a new string to it for the [out] part - it's this [out] part that VB is expecting and deleting.

          1 Reply Last reply
          0
          • G ganesa moorthy

            Hi, I am having a COM Component and i am accessing the com using VB client. In Com function i am using SysFreeString, i am calling a function inside COM DLL by passing a string argument from vbclient. After usage i am calling SysFreeString inside the com function. The above mentioned functionality works on several machines and fails(VB client crashes) in one machine. I removed the SysFreeString function call from the failing machine, and now it is fine. Can anyone tell why this happens so strangely ? Anyway we need to call SysFreeString to free up the memory. Kindly guide me! :( Advanced Thanks, Ganesha

            Thanks a lot

            G Offline
            G Offline
            GuimaSun
            wrote on last edited by
            #5

            After deallocating with sysfreestring, are you providing a new value with sysallocstring ?

            GuimaSun www.nexsun.com.br NEXSUN TechZone

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups