FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How do I clear PUBLIC and PRIVATE from memory
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
How do I clear PUBLIC and PRIVATE from memory
Posted: Fri Jan 06, 2012 04:07 AM

I've many programs (modules) link between each program. Now I would like to change all modules to login in one Main Program and choose to access in each module. The problem is: each module have PUBLIC and PRIVATE similar name.

I would like to change my programs (many modules, seperately) to single login (new main program, to use instead of login in each program (each module serperately).

Main ___ Program 1
| Program 2
|
Program 3

Any idea, most welcome.

Regards,
Dutch

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: How do I clear PUBLIC and PRIVATE from memory
Posted: Fri Jan 06, 2012 10:00 AM

Dutch,

A very good solution is to use the Class TPublic and use a single TPublic object that holds everything... :-)

viewtopic.php?p=124571#p124571

Basically you do:

public oVars

oVars = TPublic():New()

then you use (and automatically the DATAs are created) whatever value you need:

oVars:cPath = ...
oVars:cLogin = ...
oVars:cUser = ...

Class TPublic automatically adds cPath, cLogin, cUser, etc. as new DATAs of the object oVars :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: How do I clear PUBLIC and PRIVATE from memory
Posted: Fri Jan 06, 2012 10:53 AM

I use main window object cargo data to do this.

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: How do I clear PUBLIC and PRIVATE from memory
Posted: Fri Jan 06, 2012 03:33 PM

Antonio,

Would 2 publics holding a variable take more memory than one public instance of tPublic with 2 data variables?

I assume when you want to clear the variables, all you do is oVars:End() ?

Best regards,

Pete

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: How do I clear PUBLIC and PRIVATE from memory
Posted: Fri Jan 06, 2012 03:48 PM
PeterHarmes wrote:Antonio,

Would 2 publics holding a variable take more memory than one public instance of tPublic with 2 data variables?


I'm not sure about that but the point in using an object is not its memory consume.

PeterHarmes wrote:I assume when you want to clear the variables, all you do is oVars:End() ?


No. The variables, being instance variables of the object, are released when the object variable itself goes out of scope.

EMG
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I clear PUBLIC and PRIVATE from memory
Posted: Fri Jan 06, 2012 04:34 PM

How do I know, how much the PUBLIC and PRIVATE consume the memory?
How much the limitation of PUBLIC and PRIVATE?

Sorry for stupid question, I really don't know it.

Regards,
Dutch

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: How do I clear PUBLIC and PRIVATE from memory
Posted: Fri Jan 06, 2012 04:50 PM

We don't have to worry that much about memory consume anymore. The real problem about PUBLIC and PRIVATE is their extended scope that make programs more difficult to maintain. Their use must be limited to the very rare occasions in which they can be useful.

EMG

Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I clear PUBLIC and PRIVATE from memory
Posted: Wed Jan 11, 2012 09:41 AM

Dear All,

I've got ideas for this modification.

Thanks anyone.
Dutch

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: How do I clear PUBLIC and PRIVATE from memory
Posted: Wed Jan 11, 2012 11:30 AM
Dutch,

1st)
Your exclusive problem:
a) Privates are not problem
b) Public: you should set and restore each time switch program N and M

2nd) Table symbol grow and grow if not avoid us:

SELECT 1
nUnit:= Unit1+ Unit2

must be :
SELECT 1
nUnit:= FIELD-> Unit1+ FIELD-> Unit2

if not use us second option, then uni1 and unit2 will they go to symbol table.


Anex: view symbol table:
Code (fw): Select all Collapse
#Define CRLF Chr(13)+ Chr(10)
FUNCTION ViewSymbolTable()
Local c:= "", nItem, nSymbols:= __DYNSCOUNT()
FOR nItem:= 1 TO nSymbols
   c+= __DYNSGETNAME(nItem))+ CRLF
NEXT
MemoWrite("Tmp.Txt", c)
RUN ("NotePad Tmp.Txt")

RETURN NIL






Regards
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: How do I clear PUBLIC and PRIVATE from memory
Posted: Wed Jan 11, 2012 12:43 PM

Dutch,

Each Harbour variable or DATA is hold in a HB_ITEM. The size of HB_ITEM is:

HB_FUNC( GETVARSIZE )
{
hb_retnl( sizeof( HB_ITEM ) );
}

Besides this, some vars and DATA may generate a public symbol which size is sizeof( HB_DYNSYM )

Anyhow this is just for pure curiosity, because as it has been explained here, you should not worry about the memory at all, except if there is a memory leaking, tht means that the consumed memory grows and grows.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion