Page 1 of 1

EDITBOX how to release Memory ?

Posted: Tue Nov 30, 2021 11:09 am
by AUGE_OHR
hi,

i have try to load a "big" File into EDITBOX which work.
but when release Form it seems not to release EDITBOX / VALUE :o

Code: Select all

   cMemo := HB_MEMOREAD( cFile )

   DEFINE WINDOW TXTEdit ;
         ON RELEASE TXTRelease( lEdit, cFile ) ;

      DEFINE EDITBOX TXTCtrl
         VALUE cMemo

   ACTIVATE WINDOW TXTEdit

   cMemo := " "
RETURN

Code: Select all

STATIC PROCEDURE TXTRelease( lEdit, cFile )
   IF lEdit = .T.
      IF lChanged = .T.
         IF msgyesno( "Save Change ?", "TXT have change" ) == .T.
            hb_MemoWrit( cFile, TXTEdit.TXTCtrl.Value )
         ENDIF
      ENDIF
   ENDIF

   TXTEdit.TXTCtrl.Value := " "
RETURN
what can i do :?:

Re: EDITBOX how to release Memory ?

Posted: Tue Nov 30, 2021 11:13 am
by edk
:idea: Release Memory or EmptyWorkingSet() :?:

Re: EDITBOX how to release Memory ?

Posted: Tue Nov 30, 2021 11:42 am
by AUGE_OHR
hi

forgot to say : all LOCAL
edk wrote: Tue Nov 30, 2021 11:13 am :idea: Release Memory or EmptyWorkingSet() :?:
"where" to use "Release Memory" ?
how to use EmptyWorkingSet( [ ProcessID ] ) ---> lBoolean ?

thx for help

Re: EDITBOX how to release Memory ?

Posted: Tue Nov 30, 2021 1:57 pm
by edk
Maybe try:

Code: Select all

ACTIVATE WINDOW TXTEdit

EmptyWorkingSet()

Re: EDITBOX how to release Memory ?

Posted: Tue Nov 30, 2021 3:53 pm
by srvet_claudio
Hi,
for example:

TXTEdit.TXTCtrl.Value := " "
RELEASE MEMORY // this call Harbour garbage collect

Re: EDITBOX how to release Memory ?

Posted: Tue Nov 30, 2021 8:44 pm
by edk
srvet_claudio wrote: Tue Nov 30, 2021 3:53 pm Hi,
for example:

TXTEdit.TXTCtrl.Value := " "
RELEASE MEMORY // this call Harbour garbage collect
Dear Claudio.
Unfortunately, this does not free up memory, at least all "consumed" while creating Editbox.
See my demo.
demo.zip
(1.71 KiB) Downloaded 107 times
An application without a 100 MB file loaded in Editbox has approximately 1930 MB of free resources. After loading the file, the memory is reduced by 400 MB, and after releasing Editbox and "Release Memory", only 100 MB is released, still 300 MB is occupied. Each subsequent loading of a 100 MB file takes up the next 400 MB of memory.

Re: EDITBOX how to release Memory ?

Posted: Wed Dec 01, 2021 1:12 pm
by edk
It seems to me that the problem is UNICODE, if I convert HMG to ANSI the problem does not occur (memory is released in the same amount as allocated memory). I guess it has something to do with HMG_WCHAR_TO_CHAR (c) and for some reason the allocated memory is doubled and then not released :?
Unfortunately, my knowledge of C is insufficient to solve this issue :roll: