CallDll32() memory leak

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

CallDll32() memory leak

Post 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 ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
kristalist
Posts: 21
Joined: Thu Apr 23, 2015 2:30 pm
DBs Used: DBF

Re: CallDll32() memory leak

Post 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.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

CallDll32() memory leak

Post 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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

CallDll32() memory leak

Post 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
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
kristalist
Posts: 21
Joined: Thu Apr 23, 2015 2:30 pm
DBs Used: DBF

Re: CallDll32() memory leak

Post 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.
Attachments
t7dll_upd.zip
(3.95 MiB) Downloaded 242 times
Last edited by kristalist on Sun Apr 26, 2015 3:23 pm, edited 1 time in total.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

CallDll32() memory leak

Post 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
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

CallDll32() memory leak

Post 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:
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: CallDll32() memory leak

Post 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
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
kristalist
Posts: 21
Joined: Thu Apr 23, 2015 2:30 pm
DBs Used: DBF

Re: CallDll32() memory leak

Post 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
User avatar
apais
Posts: 440
Joined: Fri Aug 01, 2008 6:03 pm
DBs Used: DBF
Location: uruguay
Contact:

Re: CallDll32() memory leak

Post 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
Angel Pais
Web Apps consultant/architect/developer.
HW_apache (webserver modules) co-developer.
HbTron (Html GUI for harbour desktop hybrid apps) co-developer.
https://www.hbtron.com
Post Reply