- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经从 Liferay 6.1.1-ce-ga2 迁移了 Liferay 6.2-CE-GA2 服务器。
我对自定义 Hook 和主题做了一些更改以适应新版本。
在语言环境上,我从未遇到内存问题或 6.1 版本问题,但一旦投入生产,服务器会在几个小时内耗尽内存。
我尝试调整堆参数并增加服务器内存(从 2GB 到 3GB),但堆似乎一直在缓慢但不停地增长,直到出现 OutOfMemory: Java heap space
或,如果我对堆授予更大的限制,系统就会耗尽内存。
我已经研究了 catalina.out 好几天了,试图尽量减少警告和错误,这是我在关机重启过程中看到的唯一有趣的事情(我替换了日志中的所有域名):
[on shutdown]
WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.
WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.
[...]
28-xul-2014 16:53:51 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [org.python.google.common.base.internal.Finalizer] but has failed to stop it. This is very likely to create a memory leak.
28-xul-2014 16:53:51 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [Thread-26] but has failed to stop it. This is very likely to create a memory leak.
28-xul-2014 16:53:51 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [Thread-27] but has failed to stop it. This is very likely to create a memory leak.
[...]
16:55:40,517 ERROR [liferay/hot_deploy-1][JDBCExceptionReporter:82] Batch entry 0 insert into CalendarBooking (uuid_, groupId, companyId, userId, userName, createDate, modifiedDate, resourceBlockId, calendarId, calendarResourceId, parentCalendarBookingId, title, description, location, startTime, endTime, allDay, recurrence, firstReminder, firstReminderType, secondReminder, secondReminderType, status, statusByUserId, statusByUserName, statusDate, calendarBookingId) values ('985aac08-6457-484c-becb-2c4964805158', '10545', '10154', '10196', 'Carlos Ces', '2012-06-06 06:26:41.431000 +01:00:00', '2012-06-06 06:26:41.431000 +01:00:00', '0', '550617', '550571', '565201', 'Master Class de improvisación e tango contemporáneo con Jorge Retamoza', '<p>_ <a href="http://www.rrrrrr.es/cultura/-/blogs/master-class-de-improvisacion-e-tango-contemporaneo-con-jorge-retamoza">Master Class con Jorge Retamoza. </a></p>_<p>_ <a href="http://www.rrrrrr.es/cultura/-/blogs/master-class-de-improvisacion-e-tango-contemporaneo-con-jorge-retamoza">Organiza: Escola de Música de rrrrrr. Colabora: Concello de rrrrrr.</a></p>', 'Auditorio de rrrrrr', '1339246800000', '1339257600000', '0', '', '900000', 'email', '300000', 'email', '0', '10196', 'Carlos Ces', '2012-06-06 06:26:41.431000 +01:00:00', '565201') was aborted. Call getNextException to see the cause. [Sanitized]
16:55:40,518 ERROR [liferay/hot_deploy-1][JDBCExceptionReporter:82] ERROR: duplicate key value violates unique constraint "ix_f4c61797"
16:55:40,536 ERROR [liferay/hot_deploy-1][SerialDestination:68] Unable to process message {destinationName=liferay/hot_deploy, response=null, responseDestinationName=null, responseId=null, payload=null, values={command=deploy, companyId=0, servletContextName=calendar-portlet}}
com.liferay.portal.kernel.messaging.MessageListenerException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:32)
at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:72)
at com.liferay.portal.kernel.messaging.SerialDestination$1.run(SerialDestination.java:65)
at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:682)
at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:593)
at java.lang.Thread.run(Thread.java:636)
Caused by: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
[...]
... 5 more
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
[...]
... 62 more
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into CalendarBooking (uuid_, groupId, companyId, userId, userName, createDate, modifiedDate, resourceBlockId, calendarId, calendarResourceId, parentCalendarBookingId, title, description, location, startTime, endTime, allDay, recurrence, firstReminder, firstReminderType, secondReminder, secondReminderType, status, statusByUserId, statusByUserName, statusDate, calendarBookingId) values ('985aac08-6457-484c-becb-2c4964805158', '10545', '10154', '10196', 'Carlos Ces', '2012-06-06 06:26:41.431000 +01:00:00', '2012-06-06 06:26:41.431000 +01:00:00', '0', '550617', '550571', '565201', 'Master Class de improvisación e tango contemporáneo con Jorge Retamoza', '<p>_ <a href="http://www.rrrrrr.es/cultura/-/blogs/master-class-de-improvisacion-e-tango-contemporaneo-con-jorge-retamoza">Master Class con Jorge Retamoza. </a></p>_<p>_ <a href="http://www.rrrrrr.es/cultura/-/blogs/master-class-de-improvisacion-e-tango-contemporaneo-con-jorge-retamoza">Organiza: Escola de Música de rrrrrr. Colabora: Concello de rrrrrr.</a></p>', 'Auditorio de rrrrrr', '1339246800000', '1339257600000', '0', '', '900000', 'email', '300000', 'email', '0', '10196', 'Carlos Ces', '2012-06-06 06:26:41.431000 +01:00:00', '565201') was aborted. Call getNextException to see the cause. [Sanitized]
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2621)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1837)
[...]
... 68 more
然后服务器正常运行 5 小时,每隔几分钟就会有一些备用警告:
23:39:09,275 WARN [ajp-apr-8009-exec-20][SecurityPortletContainerWrapper:623] Reject process action for http://www.rrrrrr.com/rrrrrr25n/notadeprensa on 56_INSTANCE_rk7ADlb9Ui2w
23:43:51,234 WARN [ajp-apr-8009-exec-19][SecurityPortletContainerWrapper:623] Reject process action for http://www.rrrrrr.org/feiron/normas on 56_INSTANCE_jh6ewEPuvvjb
23:46:59,568 WARN [ajp-apr-8009-exec-5][SecurityPortletContainerWrapper:623] Reject process action for http://www.rrrrrr.es/recursos-servizossociais on 56_INSTANCE_4eX2GzETiAQb
23:55:51,177 WARN [ajp-apr-8009-exec-5][SecurityPortletContainerWrapper:623] Reject process action for http://www.rrrrrr.es/cans on 56_INSTANCE_4eX2GzETiAQb
00:00:13,713 WARN [ajp-apr-8009-exec-24][SecurityPortletContainerWrapper:623] Reject process action for http://www.rrrrrr.es/rexistro on 56_INSTANCE_4eX2GzETiAQb
00:00:25,822 WARN [ajp-apr-8009-exec-24][SecurityPortletContainerWrapper:623] Reject process action for http://www.rrrrrr.es/plenos on 110_INSTANCE_acNEFnslrX8c
然后内存问题开始了。我在日志中发布了第一个错误:
Exception in thread "http-apr-8080-exec-4" java.lang.OutOfMemoryError: Java heap space
01:00:01,223 ERROR [MemoryQuartzSchedulerEngineInstance_Worker-3][SimpleThreadPool:120] Error while executing the Runnable:
java.lang.OutOfMemoryError: Java heap space
Exception in thread "fileinstall-/home/rrrrrr/liferay-portal-6.2-ce-ga2/data/osgi/modules" Exception in thread "ajp-apr-8009-AsyncTimeout" Exception in thread "ajp-apr-8009-exec-21" at java.util.LinkedHashMap.createEntry(LinkedHashMap.java:441)
at java.util.LinkedHashMap.addEntry(LinkedHashMap.java:423)
at java.util.HashMap.put(HashMap.java:402)
Exception in thread "ajp-apr-8009-exec-24" at sun.util.resources.OpenListResourceBundle.loadLookup(OpenListResourceBundle.java:134)
Exception in thread "MemoryQuartzSchedulerEngineInstance_QuartzSchedulerThread" Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" at sun.util.resources.OpenListResourceBundle.loadLookupTablesIfNecessary(OpenListResourceBundle.java:113)
Exception in thread "ajp-apr-8009-exec-35" Exception in thread "ajp-apr-8009-exec-36" Exception in thread "ajp-apr-8009-exec-29" Exception in thread "ajp-apr-8009-exec-37" at sun.util.resources.OpenListResourceBundle.handleGetKeys(OpenListResourceBundle.java:91)
at sun.util.LocaleServiceProviderPool.getLocalizedObjectImpl(LocaleServiceProviderPool.java:353)
Exception in thread "ajp-apr-8009-exec-33" Exception in thread "ajp-apr-8009-exec-34" Exception in thread "ajp-apr-8009-exec-30" at sun.util.LocaleServiceProviderPool.getLocalizedObject(LocaleServiceProviderPool.java:284)
Exception in thread "ajp-apr-8009-exec-28" Exception in thread "ajp-apr-8009-exec-31" Exception in thread "http-apr-8080-AsyncTimeout" Exception in thread "http-apr-8080-exec-5" Exception in thread "http-apr-8080-exec-2" Exception in thread "liferay/scheduler_dispatch-3" Exception in thread "ajp-apr-8009-exec-41" at sun.util.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:111)
at sun.util.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:99)
at java.util.TimeZone.getDisplayNames(TimeZone.java:418)
at java.util.TimeZone.getDisplayName(TimeZone.java:369)
at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1110)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:899)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:869)
at org.apache.tomcat.util.http.ServerCookie.appendCookieValue(ServerCookie.java:254)
at org.apache.catalina.connector.Response.generateCookieString(Response.java:1032)
at org.apache.catalina.connector.Response.addCookie(Response.java:974)
at org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:381)
at javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
at com.liferay.portal.kernel.servlet.HttpOnlyCookieServletResponse.addCookie(HttpOnlyCookieServletResponse.java:62)
at javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
at javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
at javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
at com.liferay.portal.kernel.servlet.MetaInfoCacheServletResponse.addCookie(MetaInfoCacheServletResponse.java:128)
at javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
at com.liferay.portal.kernel.servlet.MetaInfoCacheServletResponse.addCookie(MetaInfoCacheServletResponse.java:128)
01:02:56,362 ERROR [PersistedQuartzSchedulerEngineInstance_QuartzSchedulerThread][ErrorLogger:120] An error occurred while scanning for the next triggers to fire.
org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'ds': java.lang.OutOfMemoryError: Java heap space [See nested exception: java.lang.OutOfMemoryError: Java heap space]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.getConnection(JobStoreSupport.java:771)
at org.quartz.impl.jdbcjobstore.JobStoreTX.getNonManagedTXConnection(JobStoreTX.java:71)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3808)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2751)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:264)
Caused by: java.lang.OutOfMemoryError: Java heap space
at javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
at com.liferay.portal.kernel.servlet.MetaInfoCacheServletResponse.addCookie(MetaInfoCacheServletResponse.java:128)
at com.liferay.portal.kernel.util.CookieKeys.addCookie(CookieKeys.java:99)
at com.liferay.portal.kernel.util.CookieKeys.addCookie(CookieKeys.java:63)
at com.liferay.portal.language.LanguageImpl.updateCookie(LanguageImpl.java:751)
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
01:03:00,917 ERROR [QuartzScheduler_PersistedQuartzSchedulerEngineInstance-NON_CLUSTERED_MisfireHandler][PortalJobStore:120] MisfireHandler: Error handling misfires: Unexpected runtime exception: Index: 0, Size: 0
org.quartz.JobPersistenceException: Unexpected runtime exception: Index: 0, Size: 0 [See nested exception: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.doRecoverMisfires(JobStoreSupport.java:3200)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:3947)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:3968)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:571)
at java.util.ArrayList.get(ArrayList.java:349)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1689)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.countMisfiredTriggersInState(StdJDBCDelegate.java:416)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.doRecoverMisfires(JobStoreSupport.java:3176)
... 2 more
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
Exception in thread "fileinstall-/home/rrrrrr/liferay-portal-6.2-ce-ga2/data/osgi/portal" java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space
我现在发布了一些自定义主题和 Hook 。我想知道它们的任何地方都存在内存泄漏,但我找不到它。
首先,我有一个用于博客的自定义应用程序显示模板
:
<div class="cr-blog container-fluid">
#foreach ($entry in $entries)
<div class="entry-content">
#set ($viewUrl = $currentURL.replaceFirst("\?.*$","") + "/-/blogs/" + $entry.getUrlTitle())
#set($img_ini=$entry.content.indexOf("<img"))
#if ($img_ini >= 0)
#set($img_end=$entry.content.indexOf(">",$img_ini) + 1)
#set($first_img_tag= $entry.content.substring($img_ini, $img_end))
#set($first_img_url=$first_img_tag.replaceFirst("<img.*src=\"",""))
#set($first_img_url=$first_img_url.replaceFirst("\".*",""))
#end
<div class="entry-extract">
#if ($img_ini >= 0)
<div class="extract-thumbnail">
<a href="$viewUrl">
<img src="$escapeTool.html($first_img_url)" />
</a>
</div>
#end
<div class="extract-title">
<a href="$viewUrl"><span>$entry.title</span></a>
</div>
<div class="extract-content">
<a href="$viewUrl">
<span class="extract-date">$dateFormats.getSimpleDateFormat("dd MMMMM yyyy HH:mm", $locale).format($entry.displayDate)</span>
#set($plain_content = $entry.content.replaceAll("</?[^>]+/?>", ""))
#set($res_length = 240)
#if ($res_length > $plain_content.length())
#set($res_length = $plain_content.length())
#end
<p>
$plain_content.substring(0,$res_length) ...
</p>
</a>
</div>
</div>
</div>
#end
</div>
自定义 Hook Blogshome 覆盖了 blogs_aggregator 中的一些 jsps。
view_entries.jspf
<c:choose>
<c:when test="<%= results.isEmpty() %>">
<liferay-ui:message key="there-are-no-blogs" />
<br /><br />
</c:when>
<c:otherwise>
<%
if (displayStyle.startsWith("extract-side-events")) {
List<BlogsEntry> eventsColumn = new ArrayList<BlogsEntry>();
List<BlogsEntry> mainColumn = new ArrayList<BlogsEntry>();
for (int i=0; i< results.size(); i++) {
BlogsEntry entry = (BlogsEntry) results.get(i);
if (entry.getDisplayDate().after(new Date())) {
searchContainer.setTotal(searchContainer.getTotal() - 1);
continue;
}
boolean isEvent = ((Boolean) entry.getExpandoBridge().getAttribute("evento"));
if (isEvent) eventsColumn.add(entry);
mainColumn.add(entry); /* change: add ALL to mainColumn; events are duplicated on side */
}
/* reorder eventsColumn */
TreeMap<Date, BlogsEntry> next= new TreeMap<Date, BlogsEntry>();
List<BlogsEntry> toRemove = new ArrayList<BlogsEntry>();
for (BlogsEntry entry: eventsColumn) {
Date ini = (Date) entry.getExpandoBridge().getAttribute("evento-inicio");
Date end = (Date) entry.getExpandoBridge().getAttribute("evento-remate");
Date now = new Date();
if (ini.before(now) && (end.after(now))) {
next.put(end, entry);
/* mainColumn.remove(entry); */
} else if (end.before(now)) {
toRemove.add(entry);
} else {
next.put(ini, entry);
/* mainColumn.remove(entry); */
}
}
eventsColumn.removeAll(toRemove);
/* third rearrangement: current & next are visible; past are pushed to mainColumn */
/* current ordered by end; next ordered by ini */
ArrayList<BlogsEntry> lNext = new ArrayList<BlogsEntry>(next.values());
%> <div class="home-events">
<div class="events-showdown" id="events-showdown">
<%
if (!lNext.isEmpty()) {
for (BlogsEntry entry: lNext) {
%>
<div class="carousel-item">
<%@ include file="/html/portlet/blogs_aggregator/view_entry_extract.jspf" %>
</div>
<%
}
}
%>
</div>
<script>
YUI().use('aui-carousel', function(Y) { new Y.Carousel( {contentBox: '#events-showdown',
height: 320, width: 600, intervalTime: 5 }).render(); });
</script>
<%--
<div class="home-events-nav">
<button type="button" class="btn btn-default btn-large"
onclick="document.getElementById('events-showdown').style.right =50">
<span class="glyphicon glyphicon-chevron-right"></span>
</button>
</div>
--%>
</div> <%
%> <div class="home-blogs container-fluid" > <%
for (BlogsEntry entry: mainColumn) {
%>
<%@ include file="/html/portlet/blogs_aggregator/view_entry_extract.jspf" %>
<%
}
%> </div> <%
/* original blogs styles */
} else {
for (int i = 0; i < results.size(); i++) {
BlogsEntry entry = (BlogsEntry)results.get(i);
if (entry.getDisplayDate().after(new Date())) {
searchContainer.setTotal(searchContainer.getTotal() - 1);
continue;
}
%>
<%@ include file="/html/portlet/blogs_aggregator/view_entry_content.jspf" %>
<%
}
}
%>
</c:otherwise>
</c:choose>
<c:if test="<%= enableRssSubscription %>">
<%
StringBundler rssURLParams = new StringBundler();
if (selectionMethod.equals("users")) {
if (organizationId > 0) {
rssURLParams.append("&organizationId=");
rssURLParams.append(organizationId);
}
else {
rssURLParams.append("&companyId=");
rssURLParams.append(company.getCompanyId());
}
}
else {
rssURLParams.append("&groupId=");
rssURLParams.append(themeDisplay.getScopeGroupId());
}
%>
<span class="button">
<liferay-ui:icon
image="rss"
label="<%= true %>"
method="get"
target="_blank"
url='<%= themeDisplay.getPathMain() + "/blogs_aggregator/rss?p_l_id=" + plid + rssURLParams %>'
/>
</span>
</c:if>
<c:if test="<%= !results.isEmpty() %>">
<div class="search-container">
<liferay-ui:search-paginator searchContainer="<%= searchContainer %>" />
</div>
</c:if>
view_entry_extract.jspf
<c:if test="<%= BlogsEntryPermission.contains(permissionChecker, entry, ActionKeys.VIEW) %>">
<div class="entry-content">
<%
PortletURL showBlogEntryURL = renderResponse.createRenderURL();
showBlogEntryURL.setParameter("struts_action", "/blogs_aggregator/view_entry");
showBlogEntryURL.setParameter("entryId", String.valueOf(entry.getEntryId()));
StringBundler sb = new StringBundler(8);
StringBundler ab = new StringBundler(8);
ab.append(themeDisplay.getURLPortal());
ab.append(GroupLocalServiceUtil.getGroup(entry.getGroupId()).getFriendlyURL());
ab.append("/-/blogs/");
ab.append(entry.getUrlTitle());
String viewEntryURL = ab.toString();
sb.append("&showAllEntries=1");
String viewAllEntriesURL = sb.toString();
User user2 = UserLocalServiceUtil.getUserById(entry.getUserId());
%>
<div class="entry-header">
<c:if test='<%= (Boolean) entry.getExpandoBridge().getAttribute("evento")%>'>
<div class="event-schedule">
<%
Calendar iniDate = com.liferay.portal.kernel.util.CalendarFactoryUtil.getCalendar(timeZone);
Calendar endDate = com.liferay.portal.kernel.util.CalendarFactoryUtil.getCalendar(timeZone);
iniDate.setTime(((Date) entry.getExpandoBridge().getAttribute("evento-inicio")));
endDate.setTime(((Date) entry.getExpandoBridge().getAttribute("evento-remate")));
boolean sameDay = false;
if ((iniDate.get(Calendar.DAY_OF_YEAR) == endDate.get(Calendar.DAY_OF_YEAR))
&& (iniDate.get(Calendar.YEAR) == endDate.get(Calendar.YEAR)))
sameDay = true;
String diaDaSemana = (new SimpleDateFormat("EEEE", locale)).format(iniDate.getTime());
String numeroDeDia = (new SimpleDateFormat("d", locale)).format(iniDate.getTime());
String mes = (new SimpleDateFormat("MMMM", locale)).format(iniDate.getTime());
// String hora = (new SimpleDateFormat("HH:mm", locale)).format(iniDate.getTime()) + "h";
String hora = (iniDate.get(Calendar.HOUR_OF_DAY) + new SimpleDateFormat(":mm", locale).format(iniDate.getTime()) + "h");
String numeroDeDiaFin = StringPool.BLANK;
String mesFin = StringPool.BLANK;
if (!sameDay) {
numeroDeDiaFin = (new SimpleDateFormat("d", locale)).format(endDate.getTime());
mesFin = (new SimpleDateFormat("MMMM", locale)).format(endDate.getTime());
}
%>
<%
if (sameDay) {
%>
<div class='event-date'>
<%= numeroDeDia %>
</div>
<div class='event-data'>
<div class="event-month"><%= mes %></div>
<div class="event-day"><%= diaDaSemana %></div>
<div class="event-time"><%= hora %></div>
</div>
<%
} else {
%>
<div class='event-date'>
<%= numeroDeDia %>
</div>
<div class='event-data'>
<div class="event-month"><%= mes %></div>
<div class="event-day"><%= diaDaSemana %></div>
<div class="event-time"><liferay-ui:message key="rrrrrr.events.until" /> <%= numeroDeDiaFin %>
<liferay-ui:message key="rrrrrr.events.of" /> <%= mesFin %></div>
</div>
<%
}
%>
</div>
</c:if>
</div>
<div class="entry-extract">
<%
String resumeText = StringPool.BLANK;
String resumeImage = StringPool.BLANK;
int extLength = 240;
if (entry.isSmallImage()) {
if (Validator.isNotNull(entry.getSmallImageURL()))
resumeImage = entry.getSmallImageURL();
else
resumeImage = themeDisplay.getPathImage() + "/journal/article?img_id=" + entry.getSmallImageId() + "&t=" + WebServerServletTokenUtil.getToken(entry.getSmallImageId()) ;
resumeImage.trim();
}
/* if no small image, extract first */
if ((resumeImage == null) || (resumeImage.isEmpty())) {
java.util.regex.Pattern p = java.util.regex.Pattern.compile("src=['\"]([^'\"]+)['\"]");
java.util.regex.Matcher m = p.matcher(entry.getContent());
if (m.find())
resumeImage = m.group().substring(5, m.group().length() -1);
}
resumeText = HtmlUtil.stripHtml(entry.getDescription());
resumeText.trim();
/* if no resume description, extract text */
if ((resumeText == null) || (resumeText.isEmpty())) {
resumeText = HtmlUtil.escape(StringUtil.shorten(HtmlUtil.extractText(entry.getContent()), extLength));
}
%>
<div class="extract-thumbnail">
<a href="<%= viewEntryURL %>" style="background-image: url('<%= HtmlUtil.escape(resumeImage) %>')">
<img class="asset-small-image" src="<%= HtmlUtil.escape(resumeImage) %>"/>
</a>
</div>
<div class="extract-title">
<a href="<%= viewEntryURL %>"><%= HtmlUtil.escape(entry.getTitle()) %></a>
</div>
<div class="extract-content">
<a href="<%= viewEntryURL %>">
<span class="extract-scope"><%= GroupLocalServiceUtil.getGroup(entry.getGroupId()).getDescriptiveName() %></span>
<span class="extract-date"><%= dateFormatDateTime.format(entry.getDisplayDate()) %></span>
<span><%= " " + resumeText %></span>
</a>
</div>
</div>
</div>
我无法猜测那里有任何内存泄漏,但必须有!我花了几个星期试图找到一个错误(停用 Hook 以查看错误是否仍然存在)但找不到线索。
是否有人在我的代码中看到了潜在的危险?还有什么其他方法可以跟踪 Java 内存使用情况以获取泄漏?
最佳答案
那真是乱七八糟的代码……首先不要使用 scriplets 使用 servlets。
不要抛出那么多代码来确定你的问题,然后缩小你的问题范围,以便我们可以回答。
您可以在eclipse中使用MAT take stack dump并分析哪些对象占用了最多的内存,从而分析内存泄漏的原因。
为什么要将 JSTL 与 scriplet 混合使用? JSTL 是为与 servlet 一起工作而设计的。
您将业务逻辑与表示层混为一谈,这就是强烈不推荐使用 scriplet 的原因。当您将其更改为 scriplets 时,您的代码不可读且困惑,然后我可以给您一些答案。
关于java - Liferay 6.2 迁移时的内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25012031/
我在具有 2CPU 和 3.75GB 内存 (https://aws.amazon.com/ec2/instance-types/) 的 c3.large Amazon EC2 ubuntu 机器上运
我想通过用户空间中的mmap-ing并将地址发送到内核空间从用户空间写入VGA内存(视频内存,而不是缓冲区),我将使用pfn remap将这些mmap-ed地址映射到vga内存(我将通过 lspci
在 Mathematica 中,如果你想让一个函数记住它的值,它在语法上是很轻松的。例如,这是标准示例 - 斐波那契: fib[1] = 1 fib[2] = 1 fib[n_]:= fib[n] =
我读到动态内存是在运行时在堆上分配的,而静态内存是在编译时在堆栈上分配的,因为编译器知道在编译时必须分配多少内存。 考虑以下代码: int n; cin>>n; int a[n]; 如果仅在运行期间读
我是 Python 的新手,但我之前还不知道这一点。我在 for 循环中有一个基本程序,它从站点请求数据并将其保存到文本文件但是当我检查我的任务管理器时,我发现内存使用量只增加了?长时间运行时,这对我
我正在设计一组数学函数并在 CPU 和 GPU(使用 CUDA)版本中实现它们。 其中一些函数基于查找表。大多数表占用 4KB,其中一些占用更多。基于查找表的函数接受一个输入,选择查找表的一两个条目,
读入一个文件,内存被动态分配给一个字符串,文件内容将被放置在这里。这是在函数内部完成的,字符串作为 char **str 传递。 使用 gdb 我发现在行 **(str+i) = fgetc(aFil
我需要证实一个理论。我正在学习 JSP/Java。 在查看了一个现有的应用程序(我没有写)之后,我注意到一些我认为导致我们的性能问题的东西。或者至少是其中的一部分。 它是这样工作的: 1)用户打开搜索
n我想使用memoization缓存某些昂贵操作的结果,这样就不会一遍又一遍地计算它们。 两个memoise和 R.cache适合我的需要。但是,我发现缓存在调用之间并不可靠。 这是一个演示我看到的问
我目前正在分析一些 javascript shell 代码。这是该脚本中的一行: function having() { memory = memory; setTimeout("F0
我有一种情况,我想一次查询数据库,然后再将整个数据缓存在内存中。 我得到了内存中 Elasticsearch 的建议,我用谷歌搜索了它是什么,以及如何在自己的 spring boot 应用程序中实现它
我正在研究 Project Euler (http://projecteuler.net/problem=14) 的第 14 题。我正在尝试使用内存功能,以便将给定数字的序列长度保存为部分结果。我正在
所以,我一直在做 Java 内存/注意力游戏作业。我还没有达到我想要的程度,它只完成了一半,但我确实让 GUI 大部分工作了......直到我尝试向我的框架添加单选按钮。我认为问题可能是因为我将 JF
我一直在尝试使用 Flask-Cache 的 memoize 功能来仅返回 statusTS() 的缓存结果,除非在另一个请求中满足特定条件,然后删除缓存。 但它并没有被删除,并且 Jinja 模板仍
我对如何使用 & 运算符来减少内存感到非常困惑。 我可以回答下面的问题吗? clase C{ function B(&$a){ $this->a = &$a; $thi
在编写代码时,我遇到了一个有趣的问题。 我有一个 PersonPOJO,其 name 作为其 String 成员之一及其 getter 和 setter class PersonPOJO { priv
在此代码中 public class Base { int length, breadth, height; Base(int l, int b, int h) { l
Definition Structure padding is the process of aligning data members of the structure in accordance
在 JavaScript Ninja 的 secret 中,作者提出了以下方案,用于在没有闭包的情况下内存函数结果。他们通过利用函数是对象这一事实并在函数上定义一个属性来存储过去调用函数的结果来实现这
我正在尝试找出 map 消耗的 RAM 量。所以,我做了以下事情;- Map cr = crPair.collectAsMap(); // 200+ entries System.out.printl
我是一名优秀的程序员,十分优秀!