. NET memory optimization of several experiences

Source: Internet
Author: User

Never thought about it before. NET development There is a problem of memory can not be released, always think that the GC has handled everything for me. Now GIS two development combined with three-dimensional ball development, did not think that there is such a serious memory growth, quickly memory is not enough, resulting in a variety of system instability. The sphere starts flashing, unable to create the device, OutOfMemory

1. Use the singleton carefully, the single-instance always keeps a reference to a static object, and memory is never released. As a singleton form, the workaround is to set the static reference to null in the Dispose method.

2. Improper use of character objects: too much too long a string, occupy large object heap, and try not to use string Plus, instead of StringBuilder

3. The stream object is not closed. such as file stream, network transport Stream (Httpresponse,ftpresponse)

. NET memory optimization of several experiences

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.