Thoughts about Java memory leaks in interview questions (1)

I was asked again about the problem of java memory leak. I have read the answer on the Internet a few days ago, and I also looked at the garbage collection mechanism in programming thought. Today, I still haven't expressed what I want to express. I calm down and think about it, but the conclusion is still not in place. Now decided to carefully summarize the java memory management mechanism.

aims:

1. Summarize the java memory management mechanism described in classic java books;

2. Learn to set the jvm memory configuration;

3. Write examples of memory leaks;

4. Learn to use at least one memory leak detection tool

 

1. Memory management of java classic books

1. Java classic books:

 

Books recommended on 51CTO:

http://developer.51cto.com/art/200906/129320.htm

1) Java Language Specification, Third Edition (by James Gosling) (JAVA language description, note: the original text is translated into java programming specification, but the tenth book is an official sun document, literally translated into java programming specification, in order to distinguish, here is translated Into java description)

This book is written by the inventor of Java technology and is the authoritative technical guide for the Java TM programming language. If you want to know the precise meaning of language construction, this book is the best resource. 

 2 ) EffectiveJava, Second Edition (by Joshua Bloch) ( JAVA experience collection , note: I think it is better than literal translation as effective / efficient java ) 

This book introduces 78 very practical and valuable experience rules in Java process designing . These rules of experience cover the solutions to the problems that most developers face every day. Through a comprehensive description of the technology used by the Java platform design experts, it reveals what should be done and what should not be done to produce clear, robust and efficient code. .   Each rule book appears as a short, small independent paper form, and be further illustrated by the example code. This book is comprehensive in content, clear in structure, and detailed. Can be used as a reference book for technical personnel.

3) Java Concurrency in Practice (by BrianGoetz) ( JAVA concurrent programming practice)

With the popularity of multi-core processors, the use of concurrency has become the key to building high-performance applications. Java 5 and 6 have made significant progress in the development of concurrent programs, improving the performance of the Java virtual machine, improving the scalability of concurrent classes, and adding a wealth of new concurrency building blocks. In this book, the creators of these convenience tools not only explain how they work and how to use them, but also explain the reasons for their creation and the design patterns behind them. This book can not only be the theoretical support for readers, but also the technical support for constructing reliable, scalable, and maintainable concurrent programs. This book does not only provide a list of concurrent APIs and their mechanisms. The book also provides design principles, patterns, and thinking models, so that we can better build correct and well-performing concurrent programs. The readers of this book are programmers who have some experience in Java programming, programmers who want to understand the improvements and new features of Java SE 5 and 6 in thread technology, as well as enthusiasts of Java and concurrent programming.  

4Java Puzzles:Traps, Pitfalls and Corner Cases (by Joshua Bloch)JAVA解惑)

Another classic masterpiece of the godfather of Java- JavaPuzzlers , Amazon five-star book. How much do you think you know Java ? Are you a code detective? Have you ever spent days tracking down a bug caused by traps and defects in Java or its libraries ? Do you like intelligence tests? Then this book is right for you! 

5) Thinking inJava (by Bruce Eckel) ( Java programming thought)

This book has won widespread praise from programmers around the world, and even the most obscure concepts will be invisible in the face of BruceEckel 's literal affinity and small and direct programming examples. From the basic grammar of Java to the most advanced features (in-depth object-oriented concepts, multithreading, automatic project construction, unit testing and debugging, etc.), this book can guide you step by step to easily master. From the various awards won by this book and the comments from readers from all over the world, it is not difficult to see that this is a classic. The author of this book has many years of teaching experience, has unique and in-depth insights into C , C++, and Java languages, and explains obscure and abstract concepts with easy-to-understand and small and direct examples. The book has 22 chapters, including operators, control execution flow, access control, reuse classes, polymorphism, interfaces, handling errors through exceptions, strings, generics, arrays, in-depth research on containers, Java I/O systems, Enumeration types, concurrency, and graphical user interface content. These rich contents include the basic grammar and advanced features of the Java language, which are suitable for Java programmers at all levels to read. It is also an excellent teaching material and reference book for universities and colleges to teach object-oriented programming language and Java language.

6) Better,faster, lighter Java (by Justin Gehtland, Bruce A. Tate) (轻快的java

Java developers are trapped in the quagmire of complexity and cannot extricate themselves. Our experience and capabilities are approaching their limits, and programmers spend much more time writing programs that support the chosen framework than solving real problems. We must ask, it is necessary to Java and made it so complicated ?.   The answer is no. This book shows you a way out. Whether you are maintaining an application or designing from scratch, you can go beyond the rules and greatly streamline the basic framework, development process, and final code. You can regain control of J2EE applications that were once out of control . ..   In this book, author Bruce A . Tate and Justin Gehtland will step by step and talk about them. First, they listed five basic rules. They show how to build simple, decoupled code, and tell you how to choose technology. They also analyzed how two widely used open source programs cater to these concepts. Finally, the author will use these basic concepts to build a simple but rich application to solve the problems encountered in the real world.

7) Core Java (vol. 1, 2) (by Cay S. Horstmann, Gary Cornell)  ( Java core technology)

" Java Core Technology" has been selling well since its publication, and it has been favored by readers. Each new version keeps up with the pace of development of the Java development toolbox as quickly as possible , and each version has been rewritten to adapt to Java. The latest features. This edition is no exception, it reflects the new features of Java SE 6 . The book has 14 chapters, including basic Java program structure, objects and classes, inheritance, interfaces and internal classes, graphical programming, event processing, Swing user interface components, deployment of applications and Applets , exception log assertion and debugging, generic programs Design, collection, and multi-threading. The whole book 's elaboration of Java technology is accurate in place, the narrative way is explained in a simple way, and contains a large number of examples to help readers fully understand the Java language and the relevant characteristics of the Java class library.  

8 ) The JavaVirtual Machine Specification (by Tim Linholm, Frank Yellin) ( Java Virtual Machine Specification)   

If you need to understand the byte code of the Java virtual machine , or some compilation aspects, this book will definitely get you what you want. It not only contains the specification of the machine code, but also the specification of the Java compiler and operating environment.

9 ) Robust Java: Exception Handling, Testing, and Debugging (by Stephen Stelting) ( JAVA exception handling testing and debugging)   

Handling exceptions involves knowledge of development, design, and architecture. The book is divided into 3 parts. Part I introduces the generation mechanism and usage of Java exceptions, introduces some best practices, and describes the general APIs and technologies used in various exception handling . Part II describes the design of testability, introduces failure mode analysis, discusses the abnormalities and causes of common APIs , analyzes the abnormal modes of J2EE architecture and distributed APIs . Part III discusses the execution of exception and error handling in the software development cycle, analyzes the software architecture, design patterns, testing and debugging, lists mature design patterns, introduces the impact of processing strategies on the system architecture, and describes how to build a robust system.


10 ) Java CodeConvention    (java programming specification ) The last one is of course the Java coding specification, which is officially produced by Sun. This is what every programmer needs to know in order to get the program's legibility and maintainability.

Seeing this, I feel guilty and ask myself, am I a java engineer? I’m applying for a senior Java engineer, but it’s been four years since I switched from C to Java . I have read many classic Java books. When I need it in my work, I check the information. The only way to check the information is Baidu, Google, and then Think inJava and core Java , although they solve many practical problems, they are more biased towards business and complete function points, but they are really far away from the road of technical architect who just came out, and the technology is really lost. Up? Really lost. The evaluation given by the department manager is that I am good at communicating and leading the team. Indeed, I can only use one sentence from my previous friends: you can drink, be sociable, lose your skills, how can you lose it?

2670 words are omitted , it has nothing to do with technology, personal impressions of work and life.

After the project is over, travel, wait for the year-end bonus, look at the salary card, save money for a year, and finally get some money that I can survive. ( This has to be said, it’s really impossible for a man to save money, he must have a financial management concept, and he has a financial management concept after breaking up with a girlfriend ) Resign and want to go to Baidu for an interview, but I know myself and the skills are not enough. , I didn't dare to go, I wanted to break through myself, and I didn't want to live a business trip. Years of dream, postgraduate entrance examination. Hot summer, impetuous heart, a group of beauties on campus, complacent and impetuous. Where can I calm down? Fortunately, I persisted until September . I went to Sanya and Shenzhen on November. To tell the truth, I really shouldn't go, otherwise I should still be working hard for the postgraduate entrance examination. It is best to do things in one go. Then take care of relatives in October. I went out in November, thinking that my job should be easy to find. Indeed, with such work experience, the project implementation work is easy for me, and I am good at communication. As long as I am good at communication, there are still a lot of work in this area. A securities software development company, small company interviews, online interview questions, improper, bad mentality, and then a financial system software company, which is quite large and not as strong as my previous company, bad mentality, deputy I always interviewed, and then I didn’t want to travel. Then it was an unknown foreign company with a better mentality, but the technology was not good enough, really not good enough. I downloaded an interview question from the Internet, read it roughly, and thought it was almost the same. I went to the Baidu Quality Department for an interview, first in Shanghai, a C technology expert interviewed me for Java work, of course, it was an algorithm architecture test. The enthusiastic Baidu HR eldest brother helped me contact the Beijing department of the Quality Department for an interview. I now know that my technology is really not enough. First of all, I have a bad mentality. I always think I have four years of work experience and have done so many projects. The actual ability of the problem is also very strong, the company will rush to ask. Indeed, the implementation of a business trip, do the secondary development of a lot a lot of work , this work is not what I want. But my skills are really not good enough. I have four years of work experience. If I apply for a job, even if I want to apply. Java R&D engineers don't know which level they need to reach. But in fact, when applying for a java engineer and technical books on java , I only know that core Java and Think in java have not been fully read. Think about your own needs, job needs, do you need such a short-sighted vision?

First, don’t go to a business trip company like the telecommunications industry. If you are on a business trip, you will sell yourself to the company. Second, it’s best to go to a bank or a securities company to live an easy life without affecting family life; , Go to a company with strong technology, do research and development in new technology direction, and one day become a creative generation.

Baidu is interviewing in this department, but you can also go to another department for an interview. At that time, I really should give it a try, so maybe I can be less complacent, and then concentrate on reading books to make up for my shortcomings.

Having said so much, it is nothing more than a problem. First, work cannot affect life; second, work must be planned ;


Guess you like

Origin blog.csdn.net/jifeijixufly/article/details/17509557