Project-assisted developer 1.1 beta2 (source code) added Optimization for form resources (Introduction)

Source: Internet
Author: User

Source code



The most important function of this version is to optimize the form resources, followed by code template editing.
When a large number of entities are generated each time, or multiple tabs are opened, the memory usage is very high. When you close the tab, the memory is not released in time. I thought it was a problem with my own controls. Later I created a new project and tried it. The results were amazing and I don't know why. The following describes my experiment process.
1. Create a new Windows Application
2. Create two interfaces. The first interface has only one open interface button. The second interface has a listview (I use this test here, the same is true for others ).
3. Loop 2nd times in forms, and add a guid to listview each time (the purpose is to keep the string unique ).
4. Open the form button in Form 1 to display Form 2.
Next, I will analyze the data before optimization.
The memory usage is 506 MB when no program is clicked.

After five windows are displayed, the memory usage is 608 MB, and the memory usage is 102 MB.

567 MB for closing 5 windows, 41 MB for opening 5 windows, with 61 MB of memory left and not released

The following figure shows the data after I added the optimized code.
502 MB of data is not opened when it is opened

Open 5 windows 606, 104 more

526 after all shutdown, 80 Mb is released. 24 m has not been released.

This data may be inaccurate, but I believe it will be effective after optimization.

Let's talk about the optimization ideas. Master, angry youth, and lack of quality should go away in advance. I may laugh at it because I don't know the specific principle. I can only talk about it briefly.
C # Yes, the memory is automatically released without manual sorting. It can be tested to release the whole program only when it is completely closed. A single closed form may not be released in time or for other reasons. In this case, you need to manually release multiple tabs, such as me, which may generate a large number of code tools. I need to process the memory in time. After multiple tests, it is suggested that the memory cannot be completely released due to the following reasons. When you close the form, you may only release the form resource, but the controls on the form still exist in reference, so garbage collection is not processed in time.
Therefore, you need to manually call system. gc. Collect () to forcibly Recycle resources. This method may be to recycle the space without reference in the memory. Therefore, you must set the object to null before calling this method. To forcibly recycle and process resources correctly.
My solution is to trigger close when every form is closed to set the current form to null, and then call the collect method to forcibly recycle it, it can be tested and written directly in the form. The form itself cannot be set to null. So I made a Custom Event. When the event is closed, the Custom Event is triggered to be recycled.
The above are conclusions and inferences about the test results, which are not necessarily accurate and need to be investigated. The purpose of writing this article is to warn you that it is not fixed for the CLR to automatically process the memory.

I will send you the example and test it on my own. If you have any good conclusions, please leave a message and I want to know why.
If you have any questions, add the QQ group: 63864931
Resource release source code

1.1 beta2 features (Latest Version)

1. added the template generation and editing function.
2. added the csdn network extraction collection plug-in (the plug-in may report an error-Program-plug-in management-selected plug-in, set the class library file as the path on your machine, all plug-ins are under the plug directory of the Program)
3. Simple Optimization of program memory usage

1.1 beta1 features

1. added the ability to generate entity classes in batches.
2. Added nhib.pdf object file generation
3. added the nhib.pdf object configuration file generation.
4. added the template file directory to store the template file. Currently, this directory only contains the entity template and the nhib.pdf configuration file template. You can open it and edit it on your own.

For more images, see: http://www.cnblogs.com/dirain/archive/2008/06/14/1222023.html

1.0 beta2

1. added the article collection plug-in.
2. multi-threaded Optimization of form Performance
3. corrected the type of SQL statements with parameters.

1.0 beta1

1. the main interface is similar to the vs compiler, and the interface is more familiar with it.
2. You can simulate a query analyzer to execute tsql statements.
3. Support for SQL Server 2000 and SQL Server 2005
4. Display operable data in the database in a tree menu
4. Quick viewing of table data
5. dynamically generate SQL statements with Parameters
6. entity class generation
7. Fully automated program upgrade to ensure that the latest version is available immediately

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.