Page 2 of 3

CallDll32() memory leak

Posted: Fri Apr 24, 2015 12:34 pm
by Pablo César
kristalist wrote:My goal is not to test internet connection --- but have possibility dynamical load and call any external function in std dll libraries..... :-(
Ok, sorry but know I understood.

Have you saw what Pete has wrote about our CallDll32 ?

Here in this message is my last POW about it.

Have you any comments to add ?

Re: CallDll32() memory leak

Posted: Fri Apr 24, 2015 12:55 pm
by kristalist
Hi Pablo!

I need this function, and I will try to find a solution ....
May be not so quick, because I am new in Harbour & C.
I need some time to test all variants.

CallDll32() memory leak

Posted: Fri Apr 24, 2015 1:18 pm
by Pablo César
Yes, Konstantin I also will need it !

So we can try to solved it and please let's focus our messages in this topic because it was the first bug alarmed for threating this matter.

CallDll32() memory leak

Posted: Fri Apr 24, 2015 8:57 pm
by Pablo César
Hi Konstantin,

In this HMG 3.4.0 version our CallDll32() and its sub-functions are not working properlly due a Harbour change.
It was advised by Pete and this is consagrated with tests removing from our library these concerned functions, letting Harbour functions taking place instead.

Its was for that reason you couldn't test the "pure harbour code" because our function is bugged by Harbour changes.

I hope for next version could it be fixed and you can use normally in your systems.

B.Rgds

Re: CallDll32() memory leak

Posted: Sun Apr 26, 2015 9:44 am
by kristalist
Updated ( new attachments- repaired):
Hi Pablo!

My HMG version is 3.3.1.
I find method to call CallDll32() WITHOUT memory leaks.... :-)
All us need is add copy of this routines to project file with new name. :-)

( but I don't know, may or not new "mm<Local> routines "interfere" with "memory leaks" CallDll32 routines in other libraries..... :-( )

I think better will to recompile basic libraries, but I am not a programmer, so need too much time (to me) to find what and how to recompile source of HMG. If any in this forum can understand what wrong in linking and distribution please do it ! :-) And, a bad news as a result - can be other "mistakes" in HMG with good source (?) but with bad linking and building...
So... in attach you can see last may test. In source you can remark one of two lines.

Code: Select all

      mmCallDll32( "InternetGetConnectedState", "wininet.dll", @nFlags, 0 )     // without memory leak
      //CallDll32( "InternetGetConnectedState", "wininet.dll", @nFlags, 0 )     // with memory leak
      //mmCallDll32 ( "sndPlaySoundA" , "WINMM.DLL" ,  "sample.wav" , 0 )  for real testing dll
In case using CallDll32 - you can see memory leak in test on the screen. In case using mmCallDll32() - you can see test WITHOUT memory leaks. mmCallDll32() function (with sub-functions) - its copy from original source files drom HMG distribution, only add prefiks mm... WITHOUT other change.

Best Regards
Konstantin.

CallDll32() memory leak

Posted: Sun Apr 26, 2015 1:36 pm
by Pablo César
Wow Konstantin !

Thank you for your reporting and I think you have already found out what is happining regarding CallDll32 ! :)

In other words what you said about your experience, means that CallDll32 in Harbour is leaking memory... and Harbour's CallDll32+functions are overlapping our original CallDll32. :o

Before I read your message, I sent a message to Dr. Claudio Soto asking if is there this possibility happening in this HMG 3.4.0 version.

Let's wait HMG Developement Team will decide and what they to comment.

Thank you Konstantin for your valuable information ! :D

CallDll32() memory leak

Posted: Sun Apr 26, 2015 1:41 pm
by Pablo César
[quote="kristalist"]Sorry, need testing... wrong result...[quote]Hi Konstantin,

I did not notice with this message. Have you re-edited your message ?

Let me know what is happening...

I'm wondering if in fact that's how you had mentioned at the beginning with respect to mmCallDll32 :roll:

Re: CallDll32() memory leak

Posted: Sun Apr 26, 2015 3:23 pm
by srvet_claudio
Hi Konstantin,
try with this:

Code: Select all

#include "hmg.ch"

Function Main
   nFlags := 0
   lRet   := InternetGetConnectedState (@nFlags, 0)
   MsgDebug (nFlags, lRet)
Return Nil


#pragma BEGINDUMP
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"
#include <windows.h>
#include "hbapi.h"

HMG_DEFINE_DLL_FUNC ( win_InternetGetConnectedState,                      // user function name
                      "Wininet.dll",                                      // dll name
                      BOOL,                                               // function return type
                      WINAPI,                                             // function type
                      "InternetGetConnectedState",                        // dll function name
                      (LPDWORD lpdwFlags, DWORD dwReserved),              // dll function parameters (types and names)
                      (lpdwFlags, dwReserved),                            // function parameters (only names)
                      FALSE                                               // return value if fail call function of dll
                    )


HB_FUNC ( INTERNETGETCONNECTEDSTATE )
{
   DWORD dwFlags    = 0;
   DWORD dwReserved = hb_parnl (2);
   hb_retl ((BOOL) win_InternetGetConnectedState (&dwFlags, dwReserved));
   if ( HB_ISBYREF(1) )
       hb_stornl (dwFlags, 1);
}

#pragma ENDDUMP

Re: CallDll32() memory leak

Posted: Sun Apr 26, 2015 3:36 pm
by kristalist
Hi Pablo!
Hi Dr.Claudio!

Thanks for code, I understand idea ( direct call) and will test it. :-) Main goal not to have routine for testing internet but for call my specific dlls. But as idea - thanks.

I update my test project in previous post. - in first edition I rename only CallDll32 without renaming sub-function, and , as a result - Dll not realy called.
But in last updated atachments working complex of renamed functions mmCallDll32 with mmsubroutines. And this test project normal load DLLs.

Best regards
Konstantin

Re: CallDll32() memory leak

Posted: Sun Apr 26, 2015 7:26 pm
by apais
Hi Claudio:

In my undestrding hmg's calldll function shoul be eliminated in order to allow harbour's one to be linked.
HMG's version has an ( hidden bug ) incorrect += STRING that grows forever and it only becomes aparent by calling it million times like Kostantin does.
Is that correct ?

HTH
Angel