对于我的应用程序,Java进程使用的内存远远超过堆大小.
容器正在运行的系统开始出现内存问题,因为容器占用的内存比堆大小多得多.
堆大小设置为128 MB(-Xmx128m -Xms128m
),而容器最多占用1 GB内存.在正常情况下,它需要500MB.如果docker容器具有以下限制(例如mem_limit=mem_limit=400MB
),则该进程被OS的内存不足杀死所杀死.
你能解释为什么Java进程使用比堆更多的内存吗?如何正确调整Docker内存限制?有没有办法减少Java进程的堆外内存占用?
我使用JVM中的本机内存跟踪命令收集有关该问题的一些详细信息.
从主机系统,我获得容器使用的内存.
$ docker stats --no-stream 9afcb62a26c8
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
9afcb62a26c8 xx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.0acbb46bb6fe3ae1b1c99aff3a6073bb7b7ecf85 0.93% 461MiB / 9.744GiB 4.62% 286MB / 7.92MB 157MB / 2.66GB 57
Run Code Online (Sandbox Code Playgroud)
从容器内部,我获得进程使用的内存.
$ ps -p 71 -o pcpu,rss,size,vsize
%CPU RSS SIZE VSZ
11.2 486040 580860 3814600
Run Code Online (Sandbox Code Playgroud)
$ jcmd 71 VM.native_memory
71:
Native Memory Tracking:
Total: reserved=1631932KB, committed=367400KB
- Java Heap (reserved=131072KB, …
Run Code Online (Sandbox Code Playgroud) 在我的Angular 2项目中,我从返回Observable的服务进行API调用.然后调用代码订阅此可观察对象.例如:
getCampaigns(): Observable<Campaign[]> {
return this.http.get('/campaigns').map(res => res.json());
}
Run Code Online (Sandbox Code Playgroud)
假设服务器返回401.如何全局捕获此错误并重定向到登录页面/组件?
谢谢.
这是我到目前为止所拥有的:
// boot.ts
import {Http, XHRBackend, RequestOptions} from 'angular2/http';
import {CustomHttp} from './customhttp';
bootstrap(AppComponent, [HTTP_PROVIDERS, ROUTER_PROVIDERS,
new Provider(Http, {
useFactory: (backend: XHRBackend, defaultOptions: RequestOptions) => new CustomHttp(backend, defaultOptions),
deps: [XHRBackend, RequestOptions]
})
]);
Run Code Online (Sandbox Code Playgroud)
// customhttp.ts
import {Http, ConnectionBackend, Request, RequestOptions, RequestOptionsArgs, Response} from 'angular2/http';
import {Observable} from 'rxjs/Observable';
@Injectable()
export class CustomHttp extends Http {
constructor(backend: ConnectionBackend, defaultOptions: RequestOptions) {
super(backend, defaultOptions);
}
request(url: string | Request, options?: …
Run Code Online (Sandbox Code Playgroud) 从Surefire 2.6升级到Surefire 2.13时,我TypeNotPresentExceptionProxy
在运行单元测试时得到了一个.
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
at java.lang.Class.getAnnotation(Class.java:3029)
at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.isValidJUnit4Test(JUnit4TestChecker.java:64)
Run Code Online (Sandbox Code Playgroud)
在JUnit4TestChecker
,第64行看起来像这样:
Annotation runWithAnnotation = testClass.getAnnotation( runWith );
Run Code Online (Sandbox Code Playgroud)
所以Surefire检查@RunWith
注释以确保其类型有效.我们的测试使用Spring,所以@RunWith
在我们的测试类中看起来像这样:
@RunWith(SpringJUnit4ClassRunner.class)
Run Code Online (Sandbox Code Playgroud)
似乎Surefire没有找到这个SpringJUnit4ClassRunner
班级.我不确定为什么因为在Surefire 2.6下,测试运行良好.
有任何想法吗?
使用Kafka 0.8.1.1,如何在运行时更改日志保留时间?该文件说,财产是log.retention.hours
,而是试图用它来改变kafka-topics.sh
返回此错误
$ bin/kafka-topics.sh --zookeeper zk.yoursite.com --alter --topic as-access --config topic.log.retention.hours=24
Error while executing topic command requirement failed: Unknown configuration "topic.log.retention.hours".
java.lang.IllegalArgumentException: requirement failed: Unknown configuration "topic.log.retention.hours".
at scala.Predef$.require(Predef.scala:145)
at kafka.log.LogConfig$$anonfun$validateNames$1.apply(LogConfig.scala:138)
at kafka.log.LogConfig$$anonfun$validateNames$1.apply(LogConfig.scala:137)
at scala.collection.Iterator$class.foreach(Iterator.scala:631)
at scala.collection.JavaConversions$JEnumerationWrapper.foreach(JavaConversions.scala:479)
at kafka.log.LogConfig$.validateNames(LogConfig.scala:137)
at kafka.log.LogConfig$.validate(LogConfig.scala:145)
at kafka.admin.TopicCommand$.parseTopicConfigsToBeAdded(TopicCommand.scala:171)
at kafka.admin.TopicCommand$$anonfun$alterTopic$1.apply(TopicCommand.scala:95)
at kafka.admin.TopicCommand$$anonfun$alterTopic$1.apply(TopicCommand.scala:93)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:57)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:43)
at kafka.admin.TopicCommand$.alterTopic(TopicCommand.scala:93)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:52)
at kafka.admin.TopicCommand.main(TopicCommand.scala)
Run Code Online (Sandbox Code Playgroud) 我无法使基础Angular2(最终)应用程序与以下限制性CSP一起使用.
default-src 'none';
script-src 'self';
style-src 'self';
font-src 'self';
img-src 'self' data:;
connect-src 'self'
Run Code Online (Sandbox Code Playgroud)
有一个不安全的-EVAL错误lang.js和两个zone.js.你能提供解决方案吗?
我创建了一个GitHub存储库.您也可以按照以下说明操作.
将最后一个Angular CLI与webpack 6.0.8一起使用,并使用下面的说明创建新应用程序.
ng new csp-test
Run Code Online (Sandbox Code Playgroud)
在index.html中插入定义以下限制性内容安全策略的元标记.
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none';script-src 'self';style-src 'self';font-src 'self';img-src 'self' data:;connect-src 'self'">
Run Code Online (Sandbox Code Playgroud)
然后提供申请.
ng serve
Run Code Online (Sandbox Code Playgroud)
访问http:// localhost:4200 /,由于脚本被CSP阻止,因此页面无法加载.
lang.js:335 Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src …
Run Code Online (Sandbox Code Playgroud) 我想为JAX-RS客户端实现支持HTTP/1.1和HTTP/2的JAX-RS客户端.
如果服务器支持带有HTTP/2的ALPN,则使用HTTP/2,如果服务器不提供任何信息,则使用HTTP/1.1.
我已经阅读了一些关于ALPN的文章,它似乎是可能的,但我没有找到任何支持这些协议的东西.我没有把这些插在一起.
我目前正在使用Jersey的Jetty HTTP/1.1传输连接器和HTTP/2传输连接器的自定义实现.
我想通过外部枚举定义从JAX-RS端点生成一个招摇,但生成的swagger直接包含枚举到模型的定义中.这意味着不会生成枚举文档,而是在客户端复制相同的枚举.
我使用swagger-jaxrs
依赖项来扫描我的端点并生成swagger json文件.此GitHub 存储库可用于重现该问题.我还在swagger-core存储库上创建了一个GitHub 问题.
@Api("hello")
@Path("/helloSwagger")
public class HelloSwagger {
@ApiOperation(value = "Get all unique customers", notes = "Get all customers matching the given search string.", responseContainer = "Set", response = User.class)
@GET
@Path("/getUniqueUsers")
@Produces(MediaType.APPLICATION_JSON)
public Set<User> getUniqueUsers(
@ApiParam(value = "The search string is used to find customer by their name. Not case sensitive.") @QueryParam("search") String searchString,
@ApiParam(value = "Limits the size of the result set", defaultValue = "50") @QueryParam("limit") int limit
) { …
Run Code Online (Sandbox Code Playgroud) 我有一个UITableViewController.当我点击一个单元格时,我想推送一个新视图.这工作正常,但新视图没有后退按钮.为什么是这样?
TableViewCode:
if([[NSUserDefaults standardUserDefaults] boolForKey:@"isLoggedIn"])
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
ProfileViewController* profileViewController = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];
profileViewController.message = [NSDictionary dictionaryWithObjectsAndKeys:cell.textLabel.text, @"user_login", @"default", @"message_source", nil];
switch(indexPath.row) {
case kUsernameRow:
[self.navigationController pushViewController:profileViewController animated:YES];
[profileViewController release];
break;
case kAboutRow:
break;
case kTOSRow:
break;
}
}
Run Code Online (Sandbox Code Playgroud) 有没有办法显示按容器的内存使用情况排序的docker统计信息?
我使用以下命令显示带有名称的容器,我想按内存使用情况对结果进行排序.
docker stats --format "table {{.Name}}\t{{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}"
Run Code Online (Sandbox Code Playgroud)
未排序的结果如下.
NAME CONTAINER CPU % MEM USAGE / LIMIT
kafka3.interactive.8a38c338742464ffb04d6f23fc6485391318d103 0d68b7fd49a0 1.39% 359.5 MiB / 4.833 GiB
kafka2.interactive.8a38c338742464ffb04d6f23fc6485391318d103 7e5541b0b883 1.22% 309.4 MiB / 4.833 GiB
kafka1.interactive.8a38c338742464ffb04d6f23fc6485391318d103 dff07c6d639c 0.68% 267.4 MiB / 4.833 GiB
service2.interactive.8a38c338742464ffb04d6f23fc6485391318d103 0f20a7e75823 0.06% 617.8 MiB / 4.833 GiB
consulakms.interactive.8a38c338742464ffb04d6f23fc6485391318d103 b5972262194d 3.82% 10.32 MiB / 4.833 GiB
service1.interactive.8a38c338742464ffb04d6f23fc6485391318d103 be56185a37bf 0.09% 596.3 MiB / 4.833 GiB
consumer1.interactive.8a38c338742464ffb04d6f23fc6485391318d103 05145beb209c 0.06% 574.6 MiB / 4.833 GiB
consul1.interactive.8a38c338742464ffb04d6f23fc6485391318d103 3298a8159064 0.67% 10.57 MiB / 4.833 GiB …
Run Code Online (Sandbox Code Playgroud) 在 Java 11 中,JAX-WS 已从 JDK 中删除。它可以防止wsimport
在引擎盖下使用 Maven 插件轻松生成 JAX-WS 类。我正在为 Maven 插件使用以下配置org.codehaus.mojo:jaxws-maven-plugin
。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<extension>true</extension>
<packageName>tech.myproject.service</packageName>
<wsdlFiles>
<wsdlFile>${basedir}/src/main/resources/wsdl/service.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>/wsdl/service.wsdl</wsdlLocation>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法来安装 wsimport 或使用另一个插件捆绑特定架构的 wsimport 来继续生成 WSDL 类?
java ×5
angular ×2
docker ×2
maven ×2
angular-cli ×1
apache-kafka ×1
cocoa-touch ×1
enums ×1
exception ×1
http ×1
http2 ×1
ios ×1
java-11 ×1
jax-rs ×1
jax-ws ×1
jersey ×1
jetty ×1
junit ×1
jvm ×1
linux ×1
memory ×1
objective-c ×1
rest ×1
retention ×1
surefire ×1
swagger ×1
uitableview ×1
wsdl ×1