Information générale
Catégorie:
Programmation Orientée Object
Titre:
Cross reference objects
We had an ever growing DLL (could have been an exe too). After analyzing the code for many hours we discovered the cause of the problem:
Within a method of object A we did a createobject to object B and passed A (this). In the init of object B we store the passed object in a property.
Try the following for example:
FOR nTel = 1 TO 1000
x = CreateObject( 'textbox' )
y = CreateObject( 'textbox' )
x.AddProperty( 'test', y )
y.AddProperty( 'test', x )
x = null
y = null
ENDFOR
MESSAGEBOX('Watch the memory usage in the taskmanager')
While executing this code watch the memory usage in the taskmanager. It grows up to 18 MB!!
IF you remove the link y.AddProperty( 'test', x ) not only the memory usage is growing but performance differs 20 times or more!
Our solutions will be the usage of an intermediair object z:
z point to x, z points to y and y points to z so that we can refer from y to x with y.z.x
Marco.
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement