Java、Spring、Tomcat 挂在“INFO: Initializing Spring root WebApplicationContext”处,我想我更改了整个系统允许的内存堆

发布于 2024-10-19 21:47:19 字数 671 浏览 4 评论 0原文

我正在研究 Java 内存堆分配,我认为我做了一些设置,不仅针对任何特定的 tomcat 文件夹,而且针对整个系统,因为我无法在 Spring 中运行我的应用程序,也无法使用我拥有的自定义 tomcat 文件夹也被用于测试。当我尝试运行该应用程序时,它只是挂在“INFO:初始化 Spring root WebApplicationContext”处。

我不完全清楚如何通过执行诸如 "export CATALINA_OPTS="-Xms2000m -Xmx4500m""JAVA_OPTS="-Xms2000m -Xmx4500m 之类的操作在 Linux 命令行上设置此设置-XX:MaxPermSize=4500m"

我想我不小心设置了我对云服务器(具有更高内存量)的设置,因此我给它分配了比整个系统更多的内存分配。

如果有人能让我知道我是否可以这样做,如果这可能导致问题,以及如何从我的系统中获取有关当前分配的输出,以便我可以检查/更改它,我将不胜感激。已尝试 "export CATALINA_OPTS="-Xms2000m -Xmx4500m" 但它仍然对我不起作用。

我想将所有内容恢复为默认设置。我通常在 /bin 中设置内存堆分配/startup.sh 文件位于 tomcat 文件夹中,但我认为我忘记了这一点,并且正在命令行上进行实验,

谢谢。

I was playing around with the Java memory heap allocation and I think I did something that set it not just for any specific tomcat folder but for the entire system as I can't run my application in Spring or with a custom tomcat folder that I had been also using for testing. When I try to run the application, it just hangs at "INFO: Initializing Spring root WebApplicationContext".

I am not fully clear on how I could have set this on the Linux command line by doing something like "export CATALINA_OPTS="-Xms2000m -Xmx4500m" or "JAVA_OPTS="-Xms2000m -Xmx4500m -XX:MaxPermSize=4500m"

I think I accidentally put the settings I had meant for my cloud server (which has a higher amount of memory) so I gave it more memory allocation than my entire system has.

I would appreciate any help if anyone can let me know if it is possible I did this and if this could be causing the issue and how I can get an output from my system as to the current allocation so I can check / change it, I have tried "export CATALINA_OPTS="-Xms2000m -Xmx4500m" but it still won't work for me.

I would like to restore everything to default settings. I normally set the memory heap allocation in the /bin/startup.sh file in the tomcat folder but I had forgotten this, I think, and was experimenting with things on the command line.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

枕头说它不想醒 2024-10-26 21:47:19

检查 Tomcat 的所有日志文件。 Spring WebApplicationContext 的启动可能遇到错误,但将其记录在其他地方。

对于我来说,将 Tomcat 的最大堆大小设置得太大听起来像是转移注意力。如果初始堆大小参数大于系统上的最大内存大小,Java 进程将立即失败 - Tomcat 将无法初始化 Spring 应用程序。

Check all of the log files for Tomcat. It's possible that the startup of the Spring WebApplicationContext is encountering errors, but logging it elsewhere.

Setting the max heap size too large for Tomcat sounds like a red herring to me. If the initial heap size argument is larger than the maximum size of memory on the system, the Java process will fail immediately - Tomcat will not get to the point of initializing your Spring application.

稀香 2024-10-26 21:47:19

如果从 IDE 运行服务器,请查看是否可以增加服务器超时。从命令行,您必须等待。
如果问题仍然存在,请尝试清理/重新加载应用程序

See if you can increase the server timeout if you are running it from an IDE. From command line, you'll have to wait.
If the problem persists, try cleaning /reloading the application

墟烟 2024-10-26 21:47:19

调试器的用途不就是发现错误吗?为什么不简单地以调试模式启动 Tomcat,等待它“挂起”,然后通过挂起相关线程并查看堆栈跟踪来了解它在做什么?

或者更简单的是,一旦应用程序挂起就进行“线程转储”?

Isn't finding bugs what debuggers are for? Why not simply start your Tomcat in debug mode, wait until it "hangs", and find out what it is doing by suspending the relevant thread and looking at the stack trace?

Or even simpler, do a "thread dump" once the app hangs?

花之痕靓丽 2024-10-26 21:47:19

对我来说,这是另一个无法访问的服务,

  • 春天一次又一次地重试以访问并等待,直到超时
  • 。一旦我启动另一个服务,它就会自动工作。

For me it was another service that was not reachable

  • spring was retrying again and again to reach and wating until it timeouts
  • Once I started another service it worked automatically.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文