Rubbish! (Cai Xueqi)

xiaoxiao2021-03-06  33

After the implementation of waste payment with the bag last year, the amount of garbage decreased, and the resource recovery was also increased. Everyone said this is a good policy. Before the Spring Festival, the Taipei Municipal Government announced that the opening no waste payment (no exclusive garbage bag) was opened two days, and the result was a nightmare of a garbage shipment person. A large amount of garbage is stacked in the roads in each lane, and Taipei has become a garbage town.

But this scene I can't surprise. After all, I have spent four years in China. In the past four years, the Sino-Bank City continues to hang the garbage wave, sometimes even the entire Taoyuan area is immersed in garbage bamstick, I often ride half a cycle. It is necessary to stop in the roadside vomiting, and then dizzy and continue to go, after the destination, the whole person is unable. After the big waves, you said how can I put these garbage in Taipei in my eyes, let alone these garbage in Taipei is still "fresh", unlike the garbage of the middle, two weeks or one Two months of (Write here, my typing is trembled).

Garbage problems are headache in real life, and the garbage problem is equally headache in the software technology circle.

Automatic memory management is also commonly known as garbage collection, allowing programmers to alleviate a lot of burden, and reduce opportunities for programmers to make mistakes, so it is quite popular. From early SmallTalk, Eiffel, to the recent Java, C #, Python, Rebol, Ruby ..., etc., support garbage collection. Garbage collection has almost become a new generation of high-order programming prerequisites.

In Java, you don't need to actively delete objects, but by the Java virtual machine. The Java Virtual Machine will "continuously track the situation of each object, if an object is not used, the Java virtual machine will automatically release it. And how to "continuous tracking", the actual details for the Java virtual machine will play.

In the early days, many virtual machines simply made a garbage collection into an execution, repeatedly inspected, and encountered garbage to release its memory. Because garbage collection should do not affect the execution of the original program, the virtual machine will set the priority of this execution to 0 (minimum). As a result, when there is other execution in operation, garbage collection is not collected, so it is often only collected in garbage, causing insufficient memory. However, it is not possible to increase its priority, otherwise the efficiency of Java is a big blow. So, all of our Java programmers should at least 256 MB, otherwise there is no way to perform Java development tools such as JBuilder or Visualage for Java, because these development tools themselves are a Java program specializing in memory. I even loaded 512MB of RAM on my notebook.

So many people miss C / C , they think that if Java can support automatic memory management and manual memory management, then! They even hope that the future version of Java can allow them to take the initiative to release memory, and say:

MybigObject obj = new mybigObject ();

// Do Something Here ...

DELETE OBJ;

If you are so hopeful, I advise you to die this heart early! One of the main spirit of the Java language is Robust. If Java supports these two memory management, there may be many potential bugs in the program, and the problem of improper delivery of memory will be more serious than C / C , so it is impossible Do this. Java.lang.system.gc () or java.lang.Runtime.gc () GC refers to Garbage-Collection, but according to the documentation, its role is just the "suggestion" Java virtual machine to get rubbish, and Not "guarantee" will go to the garbage. The documents are so modest, you should not give it too much hopes. It is currently what you can do for the lack of memory resource consumption.

A virtual machine that is used to use a memory management method: garbage collection is a rich and huge theme. There are hundreds of mobilities in garbage collection, and there are expertise. The algorithms used by many virtual machines are not quite the same. It is recommended that you have more than a few more.

Minor manufacturing waste: Many times, you have made a bunch of rubbish that should not be manufactured, saying that when the fixed array is used, it uses the vector, but use StringBuffer to use String ... and more. This will make garbage, and more memory is not enough.

The object that is no longer used is set as NULL as soon as possible so that it is made as a garbage.

Buying more RAMs more money (saving money, this is my favorite way).

Garbage, is it really hated? That is not exhausted, one of my favorite orchestra is called garbage (Garbage), the voice of Shirley Manson is really fascinating. It's very arrogant than the name, but the song is the idol of garbage. At this time, the garbage of Snowmann has become a satiric.

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

New Post(0)