#include "hbmemory.ch"
#include "hbclass.ch"

#ifndef __XHARBOUR__
#xtranslate Str( <x>, <y>, <z>, .F. ) => Str( <x>, <y>, <z> )
#xtranslate Str( <x>, <y>, <z>, .T. ) => LTrim( Str( <x>, <y>, <z> ) )
#xtranslate Str( <x>, <y>, <z>, <k> ) => If( <k>, LTrim( Str( <x>, <y>, <z> ) 
), Str( <x>, <y>, <z> ) )
#include "xhb.ch"
#endif

#ifdef DEFAULT
#UNDEF DEFAULT
#endif
#xcommand DEFAULT <v1> := <x1> [, <vn> := <xn> ] => ;
           If( <v1> == nil, <v1> := <x1>, ) ;
           [; If( <vn> == nil, <vn> := <xn>, ) ]

#define MAXTEST 1500


PROCEDURE MAIN()
    LOCAL n, ao := {}, nMem

    REQUEST HB_GT_WIN

    FOR n := 1 TO MAXTEST

       // here loose Harbour
       aAdd( ao, PROBLEM() )
       // ------------------

       ao[-1] := 0
       hb_gcAll( .T. )

       // Here loose xHarbour
       DEFAULT nMem := Memory( HB_MEM_USED )
       //--------------------

       #ifdef __XHARBOUR__
          ? 'Mem used -> ' + AllTrim( Str( Memory( HB_MEM_USED ) ) ) + " on " + 
AllTrim( Transform( Memory( HB_MEM_BLOCKS ), '@E 
999,999,999' ) ) + " bloqs"
       #else
          ? 'Mem used -> ' + AllTrim( Str( Memory( HB_MEM_USED ) ) )
       #endif

       IF n == MAXTEST
          ? "We lost " + AllTrim( Str( Memory( HB_MEM_USED ) - nMem ) ) + " 
Bytes"
       ENDIF

    NEXT

RETURN

FUNCTION PROBLEM()
    LOCAL cValue := {'   '}
    LOCAL oMem1 := Mem():New()
RETURN Ctl():New( oMem1, bSetGet( cValue, 1 ), 'XXXX' )

CLASS Mem
    DATA aValues INIT {}
    DATA oFriend
    METHOD New( oFriend ) CONSTRUCTOR
    METHOD AddItem( oItem ) INLINE AAdd( ::aValues, oItem )
ENDCLASS

METHOD New( oFriend ) CLASS Mem
    //::aValues := { 1, "TEST", Date(), {}, {=>} }

    IF ! Empty( oFriend )
       ::oFriend := oFriend
       oFriend:AddItem( Self )
    ENDIF

RETURN Self

CLASS Ctl
    DATA oFriend
    DATA oGet
    METHOD New( oFriend, bSetGet, cPict ) CONSTRUCTOR
ENDCLASS

METHOD New( oFriend, bSetGet, cPict ) CLASS Ctl
    oFriend:AddItem( Self )
    ::oFriend := oFriend
    ::oGet    := GetNew( 20, 20, bSetGet,, cPict )
RETURN Self

FUNCTION bSetGet( uVar, nVal )
RETURN {|u| If( PCount() > 1, uVar[nVal] := u, uVar[nVal] ) }

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
xHarbour-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to