The BUG of automatic instantiation of non-visual objects and the bug of visual instances

Source: Internet
Author: User

The BUG of automatic instantiation of non-visual objects and the bug of visual instances

PB has a hidden BUG that will occupy the memory and affect the efficiency.

 

Let's take an example.

(1) Create an invisible object n_base and check the Autolnstantiate attribute.
In the initialization event constructor, write messagebox ('constructor', 'pb-BUG -- constructor ')
In the destroy event destructor, write messagebox ('destuctor', 'pb-BUG -- destructor ')
(2) create a window w_1
(3) w_1 encapsulate a method of_test_bug1 to write
If 1 = 1 then
Else
N_base ln_base
End if
(4) w_1 encapsulate a method written in of_test_bug2
N_base ln_base
(5) place a button in w_1 and click "cb_1" to write it.
If 1 = 1 then
Else
N_base ln_base
End if
(6) place a button in w_1 and click "cb_2" to write it.
Of_test_bug1 ()
(7) place a button in w_1 and click "cb_3" to write it.
If 1 = 1 then
Else
Of_test_bug2 ()
End if

After that, run the simple example and click the buttons cb_1, cb_2, and cb_3 respectively.
Will find. Both cb_1 and cb_2 call the initialization and destruction events of the non-visual object n_base. But cb_3 does not.

 

Some methods initialize and destroy objects even if they are not called.
In this way, even if you do not want to call an object, the object will be initialized and destroyed, which will affect the efficiency and occupy the memory.

 

So how can we reduce this situation?
Method 1: handle it like the method in the button cb_3 click.
Method 2: remove the Autolnstantiate attribute of an invisible object and use the create method only when calling it.
N_base ln_base
Ln_base = create n_base
This reduces the impact.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.