java jvm内存模型

Understanding JVM Memory Model, Java Memory Management are very important if you want to understand the working of Java Garbage Collection. Today we will look into memory management in Java, different parts of JVM memory and how to monitor and perform garbage collection tuning.

要了解Java垃圾收集的工作原理 ,理解JVM内存模型对于 Java内存管理非常重要。 今天,我们将研究Java中的内存管理,JVM内存的不同部分以及如何监视和执行垃圾回收优化。

Java(JVM)内存模型 (Java (JVM) Memory Model)

As you can see in the above image, JVM memory is divided into separate parts. At broad level, JVM Heap memory is physically divided into two parts – Young Generation and Old Generation.

如上图所示,JVM内存分为多个单独的部分。 从广义上讲,JVM堆内存在物理上分为两个部分-Young GenerationOld Generation

Java中的内存管理–年轻一代 (Memory Management in Java – Young Generation)

The young generation is the place where all the new objects are created. When the young generation is filled, garbage collection is performed. This garbage collection is called Minor GC. Young Generation is divided into three parts – Eden Memory and two Survivor Memory spaces.

年轻一代是创建所有新对象的地方。 当年轻一代被填满时,将执行垃圾收集。 此垃圾回收称为Minor GC 。 年轻一代分为三部分- 伊甸园记忆和两个幸存者记忆空间。

Important Points about Young Generation Spaces:

关于年轻一代空间的要点:

  • Most of the newly created objects are located in the Eden memory space.大多数新创建的对象位于Eden存储空间中。
  • When Eden space is filled with objects, Minor GC is performed and all the survivor objects are moved to one of the survivor spaces.当伊甸园空间中充满对象时,将执行次要GC,并将所有幸存者对象移至其中一个幸存者空间。
  • Minor GC also checks the survivor objects and move them to the other survivor space. So at a time, one of the survivor space is always empty.次要GC还检查幸存者对象并将其移至其他幸存者空间。 因此,一次,幸存者空间始终是空的。
  • Objects that are survived after many cycles of GC, are moved to the Old generation memory space. Usually, it’s done by setting a threshold for the age of the young generation objects before they become eligible to promote to Old generation.在许多次GC循环后仍然存在的对象将移至旧代存储空间。 通常,可以通过设置年轻一代对象的年龄阈值,然后再有资格晋升为老一代。

Java中的内存管理–老一代 (Memory Management in Java – Old Generation)

Old Generation memory contains the objects that are long-lived and survived after many rounds of Minor GC. Usually, garbage collection is performed in Old Generation memory when it’s full. Old Generation Garbage Collection is called Major GC and usually takes a longer time.

上一代内存包含经过多次次要次要GC寿命长且可以存活的对象。 通常,垃圾回收已满时在旧代内存中执行。 旧世代垃圾回收称为专业GC ,通常需要较长时间。

停止世界大赛 (Stop the World Event)

All the Garbage Collections are “Stop the World” events because all application threads are stopped until the operation completes.

所有垃圾回收都是“世界停止”事件,因为所有应用程序线程都将停止,直到操作完成。

Since Young generation keeps short-lived objects, Minor GC is very fast and the application doesn’t get affected by this.

由于Young一代保留了短暂的对象,因此Minor GC的运行速度非常快,因此应用程序不会受到此影响。

However, Major GC takes a long time because it checks all the live objects. Major GC should be minimized because it will make your application unresponsive for the garbage collection duration. So if you have a responsive application and there are a lot of Major Garbage Collection happening, you will notice timeout errors.

但是,专业GC需要很长时间,因为它会检查所有活动对象。 应该将主要GC最小化,因为这会使您的应用程序在垃圾回收期间无响应。 因此,如果您的应用程序具有响应能力,并且发生了许多“主要垃圾收集”,您将注意到超时错误。

The duration taken by garbage collector depends on the strategy used for garbage collection. That’s why it’s necessary to monitor and tune the garbage collector to avoid timeouts in the highly responsive applications.

垃圾收集器花费的时间取决于用于垃圾收集的策略。 这就是为什么必须监视和调整垃圾收集器以避免高响应应用程序中的超时的原因。

Java内存模型–永久生成 (Java Memory Model – Permanent Generation)

Permanent Generation or “Perm Gen” contains the application metadata required by the JVM to describe the classes and methods used in the application. Note that Perm Gen is not part of Java Heap memory.

永久生成或“永久生成”包含JVM所需的应用程序元数据,用于描述应用程序中使用的类和方法。 请注意,Perm Gen不是Java Heap内存的一部分。

Perm Gen is populated by JVM at runtime based on the classes used by the application. Perm Gen also contains Java SE library classes and methods. Perm Gen objects are garbage collected in a full garbage collection.

JVM在运行时根据应用程序使用的类填充PermGen。 Perm Gen还包含Java SE库类和方法。 Perm Gen对象是在完整垃圾收集中收集的垃圾。

Java内存模型–方法区域 (Java Memory Model – Method Area)

Method Area is part of space in the Perm Gen and used to store class structure (runtime constants and static variables) and code for methods and constructors.

方法区域是Perm Gen中空间的一部分,用于存储类结构(运行时常量和静态变量)以及方法和构造函数的代码。

Java内存模型–内存池 (Java Memory Model – Memory Pool)

Memory Pools are created by JVM memory managers to create a pool of immutable objects if the implementation supports it. String Pool is a good example of this kind of memory pool. Memory Pool can belong to Heap or Perm Gen, depending on the JVM memory manager implementation.

内存池由JVM内存管理器创建,以在实现支持的情况下创建不可变对象池。 字符串池就是这种内存池的一个很好的例子。 内存池可以属于Heap或Perm Gen,具体取决于JVM内存管理器的实现。

Java内存模型–运行时常量池 (Java Memory Model – Runtime Constant Pool)

Runtime constant pool is per-class runtime representation of constant pool in a class. It contains class runtime constants and static methods. Runtime constant pool is part of the method area.

运行时常量池是类中常量池的每类运行时表示形式。 它包含类运行时常量和静态方法。 运行时常量池是方法区域的一部分。

Java内存模型– Java堆栈内存 (Java Memory Model – Java Stack Memory)

Java Stack memory is used for execution of a thread. They contain method specific values that are short-lived and references to other objects in the heap that is getting referred from the method. You should read Difference between Stack and Heap Memory.

Java Stack内存用于执行线程。 它们包含短暂的方法特定值,以及对从该方法引用的堆中其他对象的引用。 您应该阅读堆栈与堆内存之间的区别 。

Java中的内存管理– Java堆内存开关 (Memory Management in Java – Java Heap Memory Switches)

Java provides a lot of memory switches that we can use to set the memory sizes and their ratios. Some of the commonly used memory switches are:

Java提供了很多内存开关,我们可以用来设置内存大小及其比率。 一些常用的内存开关是:

VM Switch VM Switch Description
-Xms For setting the initial heap size when JVM starts
-Xmx For setting the maximum heap size.
-Xmn For setting the size of the Young Generation, rest of the space goes for Old Generation.
-XX:PermGen For setting the initial size of the Permanent Generation memory
-XX:MaxPermGen For setting the maximum size of Perm Gen
-XX:SurvivorRatio For providing ratio of Eden space and Survivor Space, for example if Young Generation size is 10m and VM switch is -XX:SurvivorRatio=2 then 5m will be reserved for Eden Space and 2.5m each for both the Survivor spaces. The default value is 8.
-XX:NewRatio For providing ratio of old/new generation sizes. The default value is 2.
VM切换器 VM切换器说明
-Xms 用于在JVM启动时设置初始堆大小
-Xmx 用于设置最大堆大小。
-Xmn 为了设置年轻一代的大小,其余空间用于老一代。
-XX:PermGen 用于设置永久代内存的初始大小
-XX:MaxPermGen 用于设置Perm Gen的最大大小
-XX:幸存者比率 为了提供Eden空间和Survivor Space的比率,例如,如果Young Generation大小为10m,并且VM开关为-XX:SurvivorRatio = 2,则将为Eden Space保留5m,为两个Survivor空间分别保留2.5m。 预设值为8。
-XX:NewRatio 用于提供新旧大小比例。 预设值为2。

Most of the times, above options are sufficient, but if you want to check out other options too then please check JVM Options Official Page.

在大多数情况下,以上选项就足够了,但是如果您也想查看其他选项,请查看JVM Options Official Page 。

Java中的内存管理– Java垃圾回收 (Memory Management in Java – Java Garbage Collection)

Java Garbage Collection is the process to identify and remove the unused objects from the memory and free space to be allocated to objects created in future processing. One of the best features of Java programming language is the automatic garbage collection, unlike other programming languages such as C where memory allocation and deallocation is a manual process.

Java Garbage Collection是从内存中识别和删除未使用的对象的过程,以及分配给将来处理中创建的对象的可用空间的过程。 Java编程语言的最佳功能之一是自动垃圾收集 ,这与其他编程语言(例如C)不同,后者的内存分配和释放是手动过程。

Garbage Collector is the program running in the background that looks into all the objects in the memory and find out objects that are not referenced by any part of the program. All these unreferenced objects are deleted and space is reclaimed for allocation to other objects.

垃圾收集器是在后台运行的程序,它可以查看内存中的所有对象,并找出该程序任何部分未引用的对象。 删除所有这些未引用的对象,并回收空间以分配给其他对象。

One of the basic ways of garbage collection involves three steps:

垃圾收集的基本方法之一涉及三个步骤:

  1. Marking: This is the first step where garbage collector identifies which objects are in use and which ones are not in use.标记 :这是第一步,垃圾收集器将识别正在使用的对象和未使用的对象。
  2. Normal Deletion: Garbage Collector removes the unused objects and reclaim the free space to be allocated to other objects.正常删除 :垃圾收集器删除未使用的对象,并回收分配给其他对象的可用空间。
  3. Deletion with Compacting: For better performance, after deleting unused objects, all the survived objects can be moved to be together. This will increase the performance of allocation of memory to newer objects.压缩压缩 :为了获得更好的性能,在删除未使用的对象之后,可以将所有剩余的对象移动到一起。 这将提高为较新对象分配内存的性能。

There are two problems with a simple mark and delete approach.

简单的标记和删除方法存在两个问题。

  1. First one is that it’s not efficient because most of the newly created objects will become unused第一个是效率不高,因为大多数新创建的对象将变为未使用状态
  2. Secondly objects that are in-use for multiple garbage collection cycle are most likely to be in-use for future cycles too.其次,在多个垃圾回收周期中使用的对象也很有可能在将来的周期中使用。

The above shortcomings with the simple approach is the reason that Java Garbage Collection is Generational and we have Young Generation and Old Generation spaces in the heap memory. I have already explained above how objects are scanned and moved from one generational space to another based on the Minor GC and Major GC.

使用简单方法的上述缺点是Java垃圾回收是分代的,并且堆内存中有Young GenerationOld Generation空间的原因。 上面我已经解释了如何根据次要GC和主要GC将对象扫描并从一个世代空间移动到另一个世代空间。

Java中的内存管理– Java垃圾回收类型 (Memory Management in Java – Java Garbage Collection Types)

There are five types of garbage collection types that we can use in our applications. We just need to use the JVM switch to enable the garbage collection strategy for the application. Let’s look at each of them one by one.

我们可以在应用程序中使用五种类型的垃圾收集类型。 我们只需要使用JVM开关来为应用程序启用垃圾回收策略即可。 让我们一一看一下。

  1. Serial GC (-XX:+UseSerialGC): Serial GC uses the simple mark-sweep-compact approach for young and old generations garbage collection i.e Minor and Major GC.Serial GC is useful in client machines such as our simple stand-alone applications and machines with smaller CPU. It is good for small applications with low memory footprint.串行GC(-XX:+ UseSerialGC) :串行GC使用简单的mark-sweep-compact方法进行青年和老年人垃圾收集,即次要和主要垃圾回收。串行GC在客户端计算机中非常有用,例如我们的简单独立应用程序和CPU较小的计算机。 这对于内存占用量少的小型应用程序非常有用。
  2. Parallel GC (-XX:+UseParallelGC): Parallel GC is same as Serial GC except that is spawns N threads for young generation garbage collection where N is the number of CPU cores in the system. We can control the number of threads using -XX:ParallelGCThreads=n JVM option.Parallel Garbage Collector is also called throughput collector because it uses multiple CPUs to speed up the GC performance. Parallel GC uses a single thread for Old Generation garbage collection.并行GC(-XX:+ UseParallelGC) :并行GC与串行GC相同,只不过它为年轻一代垃圾回收生成N个线程,其中N是系统中CPU内核的数量。 我们可以使用-XX:ParallelGCThreads=n JVM选项来控制线程数。 -XX:ParallelGCThreads=n垃圾收集器也称为吞吐量收集器,因为它使用多个CPU来提高GC性能。 并行GC使用单个线程进行旧式垃圾回收。
  3. Parallel Old GC (-XX:+UseParallelOldGC): This is same as Parallel GC except that it uses multiple threads for both Young Generation and Old Generation garbage collection.并行旧GC(-XX:+ UseParallelOldGC) :与并行GC相同,不同之处在于它同时使用多个线程进行年轻代和旧代垃圾回收。
  4. Concurrent Mark Sweep (CMS) Collector (-XX:+UseConcMarkSweepGC): CMS Collector is also referred as concurrent low pause collector. It does the garbage collection for the Old generation. CMS collector tries to minimize the pauses due to garbage collection by doing most of the garbage collection work concurrently with the application threads.CMS collector on the young generation uses the same algorithm as that of the parallel collector. This garbage collector is suitable for responsive applications where we can’t afford longer pause times. We can limit the number of threads in CMS collector using -XX:ParallelCMSThreads=n JVM option.并发标记扫描(CMS)收集器(-XX:+ UseConcMarkSweepGC) :CMS收集器也称为并发低暂停收集器。 它为旧一代进行垃圾收集。 CMS收集器通过与应用程序线程同时执行大多数垃圾收集工作来尝试最大程度地减少由于垃圾收集而造成的暂停。年轻一代的CMS收集器使用与并行收集器相同的算法。 此垃圾收集器适用于响应性应用程序,在这些应用程序中我们无法承受更长的暂停时间。 我们可以使用-XX:ParallelCMSThreads=n JVM选项来限制CMS收集器中的线程数。
  5. G1 Garbage Collector (-XX:+UseG1GC): The Garbage First or G1 garbage collector is available from Java 7 and its long term goal is to replace the CMS collector. The G1 collector is a parallel, concurrent, and incrementally compacting low-pause garbage collector.Garbage First Collector doesn’t work like other collectors and there is no concept of Young and Old generation space. It divides the heap space into multiple equal-sized heap regions. When a garbage collection is invoked, it first collects the region with lesser live data, hence “Garbage First”. You can find more details about it at Garbage-First Collector Oracle Documentation.G1垃圾收集器(-XX:+ UseG1GC) :Java 7提供了Garbage First或G1垃圾收集器,其长期目标是替换CMS收集器。 G1收集器是并行的,并发的,渐进压缩的低暂停垃圾收集器。垃圾优先收集器的工作方式与其他收集器不同,并且没有年轻一代和老一代空间的概念。 它将堆空间划分为多个大小相等的堆区域。 调用垃圾回收时,它将首先收集实时数据较少的区域,因此称为“垃圾优先”。 您可以在Garbage-First Collector Oracle文档中找到有关它的更多详细信息。

Java中的内存管理– Java垃圾收集监控 (Memory Management in Java – Java Garbage Collection Monitoring)

We can use the Java command line as well as UI tools for monitoring garbage collection activities of an application. For my example, I am using one of the demo application provided by Java SE downloads.

我们可以使用Java命令行以及UI工具来监视应用程序的垃圾回收活动。 对于我的示例,我使用的是Java SE下载提供的演示应用程序之一。

If you want to use the same application, go to Java SE Downloads page and download JDK 7 and JavaFX Demos and Samples. The sample application I am using is Java2Demo.jar and it’s present in jdk1.7.0_55/demo/jfc/Java2D directory. However this is an optional step and you can run the GC monitoring commands for any java application.

如果要使用相同的应用程序,请转到Java SE下载页面并下载JDK 7和JavaFX演示和样本 。 我使用的示例应用程序是Java2Demo.jar ,它存在于jdk1.7.0_55/demo/jfc/Java2D目录中。 但是,这是可选步骤,您可以为任何Java应用程序运行GC监视命令。

Command used by me to start the demo application is:

我用来启动演示应用程序的命令是:

pankaj@Pankaj:~/Downloads/jdk1.7.0_55/demo/jfc/Java2D$ java -Xmx120m -Xms30m -Xmn10m -XX:PermSize=20m -XX:MaxPermSize=20m -XX:+UseSerialGC -jar Java2Demo.jar

统计 (jstat)

We can use jstat command line tool to monitor the JVM memory and garbage collection activities. It ships with standard JDK, so you don’t need to do anything else to get it.

我们可以使用jstat命令行工具来监视JVM内存和垃圾回收活动。 它与标准JDK一起提供,因此您无需执行任何其他操作即可获得它。

For executing jstat you need to know the process id of the application, you can get it easily using ps -eaf | grep java command.

为了执行jstat您需要了解应用程序的进程ID,可以使用ps -eaf | grep java轻松获得它ps -eaf | grep java ps -eaf | grep java命令。

pankaj@Pankaj:~$ ps -eaf | grep Java2Demo.jar501 9582  11579   0  9:48PM ttys000    0:21.66 /usr/bin/java -Xmx120m -Xms30m -Xmn10m -XX:PermSize=20m -XX:MaxPermSize=20m -XX:+UseG1GC -jar Java2Demo.jar501 14073 14045   0  9:48PM ttys002    0:00.00 grep Java2Demo.jar

So the process id for my java application is 9582. Now we can run jstat command as shown below.

因此,我的Java应用程序的进程ID为9582。现在,我们可以运行jstat命令,如下所示。

pankaj@Pankaj:~$ jstat -gc 9582 1000S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT
1024.0 1024.0  0.0    0.0    8192.0   7933.3   42108.0    23401.3   20480.0 19990.9    157    0.274  40      1.381    1.654
1024.0 1024.0  0.0    0.0    8192.0   8026.5   42108.0    23401.3   20480.0 19990.9    157    0.274  40      1.381    1.654
1024.0 1024.0  0.0    0.0    8192.0   8030.0   42108.0    23401.3   20480.0 19990.9    157    0.274  40      1.381    1.654
1024.0 1024.0  0.0    0.0    8192.0   8122.2   42108.0    23401.3   20480.0 19990.9    157    0.274  40      1.381    1.654
1024.0 1024.0  0.0    0.0    8192.0   8171.2   42108.0    23401.3   20480.0 19990.9    157    0.274  40      1.381    1.654
1024.0 1024.0  48.7   0.0    8192.0   106.7    42108.0    23401.3   20480.0 19990.9    158    0.275  40      1.381    1.656
1024.0 1024.0  48.7   0.0    8192.0   145.8    42108.0    23401.3   20480.0 19990.9    158    0.275  40      1.381    1.656

The last argument for jstat is the time interval between each output, so it will print memory and garbage collection data every 1 second.

jstat的最后一个参数是每个输出之间的时间间隔,因此它将每1秒打印一次内存和垃圾回收数据。

Let’s go through each of the columns one by one.

让我们逐一浏览每个列。

  • S0C and S1C: This column shows the current size of the Survivor0 and Survivor1 areas in KB.S0C和S1C :此列以KB为单位显示Survivor0和Survivor1区域的当前大小。
  • S0U and S1U: This column shows the current usage of the Survivor0 and Survivor1 areas in KB. Notice that one of the survivor areas are empty all the time.S0U和S1U :此列显示以KB为单位的Survivor0和Survivor1区域的当前用法。 请注意,幸存者区域之一始终是空的。
  • EC and EU: These columns show the current size and usage of Eden space in KB. Note that EU size is increasing and as soon as it crosses the EC, Minor GC is called and EU size is decreased.EC和EU :这些列显示以字节为单位的Eden空间的当前大小和使用情况。 请注意,EU大小正在增加,一旦越过EC,就会调用次GC,而EU大小会减小。
  • OC and OU: These columns show the current size and current usage of Old generation in KB.OC和OU :这些列以KB为单位显示“ Old Generation”的当前大小和当前使用情况。
  • PC and PU: These columns show the current size and current usage of Perm Gen in KB.PC和PU :这些列显示Perm Gen的当前大小和当前用法(以KB为单位)。
  • YGC and YGCT: YGC column displays the number of GC event occurred in young generation. YGCT column displays the accumulated time for GC operations for Young generation. Notice that both of them are increased in the same row where EU value is dropped because of minor GC.YGC和YGCT :YGC列显示年轻一代中发生的GC事件的数量。 YGCT列显示Young代GC操作的累积时间。 请注意,由于GC较小,这两个值都在同一行中增加,而EU值下降了。
  • FGC and FGCT: FGC column displays the number of Full GC event occurred. FGCT column displays the accumulated time for Full GC operations. Notice that Full GC time is too high when compared to young generation GC timings.FGC和FGCT :FGC列显示发生Full GC事件的次数。 FGCT列显示Full GC操作的累积时间。 请注意,与年轻一代的GC计时相比,完整的GC时间太高。
  • GCT: This column displays the total accumulated time for GC operations. Notice that it’s sum of YGCT and FGCT column values.GCT :此列显示GC操作的总累积时间。 请注意,它是YGCT和FGCT列值的总和。

The advantage of jstat is that it can be executed in remote servers too where we don’t have GUI. Notice that the sum of S0C, S1C and EC is 10m as specified through -Xmn10m JVM option.

jstat的优点是它也可以在没有GUI的远程服务器中执行。 请注意,通过-Xmn10m JVM选项指定, -Xmn10m ,S1C和EC的总和为10m。

带有Visual GC的Java VisualVM (Java VisualVM with Visual GC)

If you want to see memory and GC operations in GUI, then you can use jvisualvm tool. Java VisualVM is also part of JDK, so you don’t need to download it separately.

如果要在GUI中查看内存和GC操作,则可以使用jvisualvm工具。 Java VisualVM也是JDK的一部分,因此您不需要单独下载它。

Just run jvisualvm command in the terminal to launch the Java VisualVM application. Once launched, you need to install Visual GC plugin from Tools -< Plugins option, as shown in below image.

只需在终端中运行jvisualvm命令以启动Java VisualVM应用程序。 一旦启动,您需要从Tools-<Plugins选项安装Visual GC插件,如下图所示。

After installing Visual GC, just open the application from the left side column and head over to Visual GC section. You will get an image of JVM memory and garbage collection details as shown in below image.

安装Visual GC之后 ,只需从左侧列打开应用程序,然后转到Visual GC部分。 您将获得JVM内存和垃圾回收详细信息的图像,如下图所示。

Java垃圾收集优化 (Java Garbage Collection Tuning)

Java Garbage Collection Tuning should be the last option you should use for increasing the throughput of your application and only when you see a drop in performance because of longer GC timings causing application timeout.

只有在由于较长的GC计时导致应用程序超时而导致性能下降时,才应使用Java垃圾收集优化来提高应用程序的吞吐量。

If you see java.lang.OutOfMemoryError: PermGen space errors in logs, then try to monitor and increase the Perm Gen memory space using -XX:PermGen and -XX:MaxPermGen JVM options. You might also try using -XX:+CMSClassUnloadingEnabled and check how it’s performing with CMS Garbage collector.

如果在日志中看到java.lang.OutOfMemoryError: PermGen space错误,请尝试使用-XX:PermGen和-XX:MaxPermGen JVM选项监视并增加Perm Gen的内存空间。 您也可以尝试使用-XX:+CMSClassUnloadingEnabled并检查其在CMS Garbage collector中的运行情况。

If you see a lot of Full GC operations, then you should try increasing Old generation memory space.

如果看到很多Full GC操作,则应尝试增加Old generation的内存空间。

Overall garbage collection tuning takes a lot of effort and time and there is no hard and fast rule for that. You would need to try different options and compare them to find out the best one suitable for your application.

总体上,垃圾回收调整需要大量的精力和时间,对此没有硬性规定。 您将需要尝试不同的选项并进行比较,以找出最适合您的应用程序的选项。

That’s all for Java Memory Model, Memory Management in Java and Garbage Collection, I hope it helps you in understanding JVM memory and garbage collection process.

Java内存模型,Java和垃圾收集中的内存管理全部用于此,希望它可以帮助您了解JVM内存和垃圾收集过程。

翻译自: https://www.journaldev.com/2856/java-jvm-memory-model-memory-management-in-java

java jvm内存模型

java jvm内存模型_Java(JVM)内存模型– Java中的内存管理相关推荐

  1. java 内存类_Java学习——类的生命周期和内存

    常识是本能,有足够的常识便是天才.--肖伯纳 一.类的生命周期 类的生命周期:1.加载:将二进制流加载进来.class 2.连接: 验证:确保加载进来的数据不会损害虚拟机 准备:为类变量分配内存,附默 ...

  2. java 图片 内存溢出_Java修改图片尺寸,总是报内存溢出怎么解决?

    项目需求:有很多尺寸很大的图片(图片大小可能几十MB,甚至上百MB),需要等比例缩小它们的尺寸,相当于生成缩略图. 例如:原图8268x6201,需要压缩成400x300. 我现在的方法:将图片整个读 ...

  3. java maxpermsize 设多少_java JVM : Xms Xmx PermSize MaxPermSize 区别

    java JVM : Xms Xmx PermSize MaxPermSize 区别 java JVM虚拟机选项: Xms Xmx PermSize MaxPermSize 区别 Xms 是指设定程序 ...

  4. java底层模型_Java I/O模型及其底层原理,夯实你的开发基础

    前言 Java I/O是Java基础之一,在面试中也比较常见,在这里我们尝试通过这篇文章阐述Java I/O的基础概念,帮助大家更好的理解Java I/O. 在刚开始学习Java I/O时,我很迷惑, ...

  5. java委托事件模型_JAVA授权事件模型讲解(原创)

    JAVA的授权事件模型包含三个概念:事件源,事件,事件监听器. 一,事件源:一个产生事件的对象.当这个对象的内部状态改变时,事件就会产生.一个事件源必须注册一个事件监听器已使监听器能够可以接受一个特定 ...

  6. java的jvm是指_java JVM原理与常识知识点

    JVM是Java Virtual Machine(Java虚拟机)的缩写,JVM是一种用于计算设备的规范,它是一个虚构出来的计算机,是通过在实际的计算机上仿真模拟各种计算机功能来实现的.Java虚拟机 ...

  7. java中reactor模型_Java——Netty Reactor模型(转)

    1. Reactor三种线程模型 1.1. 单线程模型 Reactor单线程模型,指的是所有的IO操作都在同一个NIO线程上面完成,NIO线程的职责如下: 1)作为NIO服务端,接收客户端的TCP连接 ...

  8. Java改知能机_Java 面试突击之 Java 并发知识基础 进阶考点全解析

    版权说明:本文内容根据 github 开源项目整理所得 项目地址:https://github.com/Snailclimb/JavaGuide​github.com 一.基础 什么是线程和进程? 何 ...

  9. java 基础知识巩固_Java基础巩固——《Java核心技术基础·卷一:基础知识》

    阅读记录追踪:前言部分 阅读前先看:简介.目录和勘误! Java编程语言是一种多用途.并发的.基于类的.面向对象的编程语言:编译时通常包括将持续转化成机器无关的字节码表示.运行时活动包括加载和链接执行 ...

  10. java面向对象基础代码_JAVA基础知识点之Java面向对象

    特点:1:将复杂的事情简单化. 2:面向对象将以前的过程中的执行者,变成了指挥者. 3:面向对象这种思想是符合现在人们思考习惯的一种思想. 过程和对象在我们的程序中是如何体现的呢? 过程其实就是函数: ...

最新文章

  1. 疫情之下,“无接触”生意火了
  2. 网易2017校招编程:优雅的点
  3. CodeForces - 287C Lucky Permutation(构造)
  4. 天池 在线编程 数组游戏
  5. 深度学习笔记(22) Padding
  6. mysql 命令限制_MySQL 命令总结
  7. eclipse 返回上一个选项卡、注释及取消注释 、大写变小写、 光标跳到下一行快捷键
  8. Mac 安装IE浏览器
  9. 蓝桥杯——等差素数列(c语言)
  10. 【新知实验室 TRTCIM】实时互动课堂最佳实践
  11. 制造商朝DOE LED功效目标迈进稳步前进
  12. 基于堆栈的缓冲区溢出_基于堆栈溢出问题构建搜索引擎
  13. JPEG/Exif/TIFF格式解读(1):JEPG图片压缩与存储原理分析
  14. 小米8样张彩色噪点问题分析
  15. 昆石VOS2009/VOS3000 2.1.6.00 操作指南
  16. MySQL数据库 学习(二)架构系统表
  17. 变基的风险以及如何用变基解决变基
  18. 小程序毕业设计 基于微信棋牌室小程序毕业设计开题报告功能参考
  19. arduino 温度调节器_怎样使用Arduino制作自己的温度控制器
  20. mysql 组合查询_mysql组合查询

热门文章

  1. java内存管理的一些基础,内存溢出的解决方案
  2. 理解JavaScript函数(函数和对象的区别和联系)
  3. 了解Python编程——Python学习(三)
  4. android——数据库版本升/降级问题
  5. ObjectARX代码片段三
  6. route debugger
  7. 我新浪的免费邮箱这段时间总是登不上去或是不稳定
  8. 代码也浪漫——Python烟花秀
  9. 数据结构笔记(二十)--二叉树的存储
  10. 【华为2015暑期实习生上机题】仿照Excel的列编号