How do I clear PUBLIC and PRIVATE from memory

How do I clear PUBLIC and PRIVATE from memory

Postby dutch » Fri Jan 06, 2012 4: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 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I clear PUBLIC and PRIVATE from memory

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42086
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How do I clear PUBLIC and PRIVATE from memory

Postby ADutheil » 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
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: How do I clear PUBLIC and PRIVATE from memory

Postby PeterHarmes » Fri Jan 06, 2012 3: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
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: How do I clear PUBLIC and PRIVATE from memory

Postby Enrico Maria Giordano » Fri Jan 06, 2012 3: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
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How do I clear PUBLIC and PRIVATE from memory

Postby dutch » Fri Jan 06, 2012 4: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 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I clear PUBLIC and PRIVATE from memory

Postby Enrico Maria Giordano » Fri Jan 06, 2012 4: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
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How do I clear PUBLIC and PRIVATE from memory

Postby dutch » Wed Jan 11, 2012 9:41 am

Dear All,

I've got ideas for this modification.

Thanks anyone.
Dutch
Regards,
Dutch

FWH 19.01 / 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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I clear PUBLIC and PRIVATE from memory

Postby hmpaquito » 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: Select all  Expand view

#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
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: How do I clear PUBLIC and PRIVATE from memory

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42086
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests