On Fri, 02 May 2008, Juan Gálvez wrote:
Hi Juan,
> Attached you can see a xHarbour test ( HB_MEM_BLOCKS doesn't exist in
> Harbour FM.C ) that shows how memory blocks go increasing when we call
> DbUseArea() with new file name.
> Is it a normal behavior ?
Yes it is. For each public symbol used in your code HVM allocates
entry in dynamic symbol table and your code shows it. Public functions,
public and private variables, fields and aliases are collected together
and registered in a one table. Each unique name is registered only
once and later reused by HVM code. Registered symbols are freed only
in HVM quit procedure and never during runtime because we cannot detect
if some code have some references to them. Such mechanism can be
implemented but it will cause some RT overhead and it will force
3-rd party code updating. Because number of unique symbols you can
use in 99% of application is static or nearly static then it's not
worth to make such modification though I can imagine some applications
where it will be useful. Clipper also make the same and does not free
unused symbols but size of symbol table in Clipper is much smaller then
in Harbour.
In your test in first loop two new symbols are allocated: "ONE" for
field name and "_F1" for alias name. Of course if rest of code do
not have such symbols and they are 1-st time used. In next loop
additional symbols for alias names ("_F2", "_F3", ...) are allocated.
If you change:
DbUseArea( .T., "DBFCDX", cDbf )
to:
DbUseArea( .T., "DBFCDX", cDbf, "MYALIAS" )
then you will see that only in 1-st loop additional memory for new
symbols is allocated and in next does not change.
Maximal number of symbols is 65535. Over this limit HVM will crash.
Maximal amount of memory allocated for new symbols is:
65535 * (16 + 12 + 5 + symbolnamelen)
All symbols used by your code explicitly (functions, function calls,
aliases, memvars know during compilation) are registered at application
startup without allocating additional memory for HB_SYMB structure because
they are used directly from symbol table generated at the beginning of
compiled .prg code. You can see it in generated .c files.
HTH
best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour