EDITBOX how to release Memory ?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

EDITBOX how to release Memory ?

Post 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 :?:
have fun
Jimmy
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: EDITBOX how to release Memory ?

Post by edk »

:idea: Release Memory or EmptyWorkingSet() :?:
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: EDITBOX how to release Memory ?

Post 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
have fun
Jimmy
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: EDITBOX how to release Memory ?

Post by edk »

Maybe try:

Code: Select all

ACTIVATE WINDOW TXTEdit

EmptyWorkingSet()
User avatar
srvet_claudio
Posts: 2224
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: EDITBOX how to release Memory ?

Post by srvet_claudio »

Hi,
for example:

TXTEdit.TXTCtrl.Value := " "
RELEASE MEMORY // this call Harbour garbage collect
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: EDITBOX how to release Memory ?

Post 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.
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: EDITBOX how to release Memory ?

Post 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:
Post Reply