Performance Loss in the stack

Source: Internet
Author: User
Tags stack trace

Reprinted from: http://kb.cnblogs.com/page/162988/

 

Stack trace)

I'm curious about this problem. I 've observed what happens when these stack trace information is collected. This is common. You will record an exception and its stack trace information to find out what the problem is.

So I modifiedCodeTo obtain the stack trace information of an exception. The situation has changed significantly. Obtaining abnormal stack tracing information is 10 times more performance pressure than simply capturing and throwing them. Therefore, the stack trace information helps us understand what went wrong or even why, but it also brings performance penalties.

This usually has a huge impact on performance, because we don't just face a stack trace. In most cases, an exception throw-capture occurs at multiple levels. Let's take a look at a simple web service connection server example. First, exceptions that fail to be connected are generated at the Java class library. The failure of the client will be captured by the framework, and some service logic calls at the application layer will throw an exception. Now, three types of stack trace information are collected.

In most cases, you can view these log files and application output information. Recording these long stack information can also bring performance impact. If you regularly view your log files, you will usually study them and respond to the problem-this is what you want to do, isn't it ?; -)

Sometimes I can see more serious performance problems caused by incorrect log writing. Instead of calling log. isxxenabled () to check whether a log-level log behavior is open, developers directly call the logging method. When you do this, the log code always returns abnormal stack trace information during execution. However, because the log level settings are too low, you may never see this information, and you may not know what happened. First, check the log record level. This should be considered a basic habit, which will avoid unnecessary objects.

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.