Discover a very strange phenomenon - memory occupation of the VB program

xiaoxiao2021-03-05  47

Let's take a look at the simple program below: an form, no controls

Private sub form_load () me.windowState = 1ME.HIDEEND SUB

We make this program slightly modified, join a Timer control:

Dim Formhide as Boolean

Private sub hideform () FORMHIDE = Trueme.WindowState = 1ME.HIDEEND SUB

Private sub form_load () Timer1.Iterval = 1000timer1.enabled = TrueEnd Sub

Private sub timer1_timer () if FormTimtimtimer1.enabled = false ifend sub

Which program do you think is less memory resources? Everyone will definitely say that it is the first program because the second program uses a Timer control to call the HIDEFORM process, which is definitely more. I thought I think so at first. But in fact, the second program takes up the memory than the first few! Don't believe you can try: Building two project project1.vbp and project2.vbp, Project1 is form1, Project2 is form2 in Form2 Add a Timer Control in Form2, then enter the above code to compile the above code to Project1.exe And Project2.exe running these two programs to open the Windows Task Manager, find Project1 and Project2 Compare, I will test the result of the test1 in Project1, and Project2 takes only 1020K!

转载请注明原文地址:https://www.9cbs.com/read-32809.html

New Post(0)