Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if Spring Cloud development takes up too much memory?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you the "Spring Cloud development memory footprint is too high how to do", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "Spring Cloud development memory footprint is too high how to do" this article.

Question:

A very serious resource problem in the process of developing spring cloud is that it takes up too much memory, but in fact, the local development test does not have a large number of requests, so it is a serious waste of computer resources, and even leads to IDE stuck and crashed.

A single service that fully includes a series of spring cloud bucket applications and other business-related components, such as eureka,steam,sleuth,config,rabbit,oauth3, takes up 1 to 1.5 gigabytes of memory to start on a 12-gigabyte computer. If you need to start many services at the same time, there is not enough memory.

Solution:

Modify the jvm parameters of IDE for each project.

Take idea as an example:

1. Open Edit Configurations

The upper right corner of Idea, as shown below:

two。 Refer to the following configuration:

If it is spring cloud on the left, it must be under spring boot. If not, you can click the + sign in the upper left corner to add it manually. There will be projects that have been started here.

I'll talk about the jvm parameter later.

Note here that the register project does not require too many resources (I set 128m here), and Gateway and config services can be a little more than register (256m). Other business services require more resources (512m).

Please adjust according to the configuration of your computer. My computer has 12g of memory.

3. About jvm configuration

Reference 1: http://blog.csdn.net/sdujava2011/article/details/50086933 has the following description

There are four parameters for setting JVM memory:

-the maximum value of Xmx Java Heap. The default value is 1x4 of physical memory. The best setting value should depend on the physical memory size and other memory overhead in the computer.

-Xms Java Heap initial value, server JVM had better set-Xms and-Xmx to the same value, and the development test machine JVM can keep the default value.

-Xmn Java Heap Young area size. If you are not familiar with it, you'd better keep the default value.

-Xss the Stack size of each thread. If you are not familiar with it, you'd better keep the default value.

Reference 2: https://www.cnblogs.com/w-wfy/p/6415856.html has the following description:

Generally speaking, the most frequently used is

-Xms512m sets JVM to cause memory to be 512m. This value can be set to the same as-Xmx to prevent JVM from reallocating memory after each garbage collection.

-Xmx512m, set the maximum available memory of JVM to 512m.

-Xmn200m: set the size of the younger generation to 200m. Whole heap size = young generation size + old generation size + lasting generation size. The permanent generation usually has a fixed size of 64m, so increasing the size of the younger generation will reduce the size of the old generation. This value has a great impact on system performance, and Sun officially recommends that it be configured as 3Universe 8 of the entire heap.

-Xss128k: sets the stack size for each thread. The stack size of each thread after JDK5.0 is 1m, and the stack size of each thread before is 256K. Adjust the amount of memory required by more applicable threads. Decreasing this value generates more threads under the same physical memory. However, the operating system still has a limit on the number of threads in a process, which cannot be generated indefinitely, and the experience value is about 3000 to 5000.

Effect.

The effect is obvious.

12 GB of memory starts 14 services and various other software (3 idea), and the memory footprint is shown below:

The above is all the contents of this article "what to do if the memory consumption of Spring Cloud development is too high?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report