All posts by 龙生
English Learning Diary 2025-09-17
Did you see this kid on your way home? Did you lose your wallet at the bar? What are your plans for Chrismas Eve? Do you still have double rooms available? If you need a pencil, put your hand up. They stopped at the hospital yesterday. Will you return to this hotel after lunch. Go downstairs, and then turn left. These shor stories are in Japanese. You left your keys in the door. What were you doing all day yesterday? Excuse me, do you mind if we stay […]
View Detailsjsp、freemarker、velocity、thymeleaf页面方案分析
在java领域,表现层技术主要有三种,
(1)jsp;
(2)freemarker;
(3)velocity;
(4)thymeleaf;
English Learning Diary 2025-09-12
If you buy a dress, you’ll get a pair of earrings for free! Look, this shop sells the best swimsuits! If you buy two swimsuits, you can get a pair of earings for free! Do you want to get anything? Do you sell the earrings that this movie star is wearing? That shop has many things that I want to buy. I like the movie star who is wearing the yellow swimsuit! She gave this to me for free, so I didn’t have to pay for it. This […]
View DetailsEnglish Learning Diary 2025-09-11
He paid with Alipay. I paid ten dollars for this scarf. You paid too much for those shoes. Yeah, I want to return them. I paid for these books with Alipay. The scarf you like is sold. The swimsuit that Emma wants is sold. The dress that you like is sold. Emma got her sister a beautiful swimsuit. I had so much fun shopping today! I got the most beautiful skirt! My mom got me an amazing dress. I’m waiting in line now. They waited in line for […]
View DetailsKafka 内存池MemoryPool 设计
GarbageCollectedMemoryPool 是一个非常巧妙的调试工具。它通过继承 SimpleMemoryPool 复用了内存额度控制的逻辑,然后通过重写钩子方法和结合Java的引用机制,增加了一层“内存泄漏”的监控。
正常流程:tryAllocate() -> bufferToBeReturned (登记) -> 使用 -> release() -> bufferToBeReleased (注销) -> ByteBuffer 失去引用 -> 被GC。
泄漏流程:tryAllocate() -> bufferToBeReturned (登记) -> 使用 -> 忘记调用 release() -> ByteBuffer 失去引用 -> 被GC -> BufferReference 进入队列 -> 后台线程检测到,并从 buffersInFlight 中找到了登记信息 -> 报告错误。
Java中Redis的ValueOperations.set后,Key乱码的解决方法
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
@Configuration @EnableCaching public class RedisConfig extends CachingConfigurerSupport { @Bean public RedisTemplate<String,Object> redisTemplate(LettuceConnectionFactory lettuceConnectionFactory){ RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); //设置String类型的key设置序列化器 redisTemplate.setKeySerializer(new StringRedisSerializer()); //设置Hash类型的key设置序列化器 redisTemplate.setHashKeySerializer(new StringRedisSerializer()); //设置redis链接Lettuce工厂 redisTemplate.setConnectionFactory(lettuceConnectionFactory); return redisTemplate; } } |
View Details
Java进阶(JVM调优)——JVM调优参数 & JDK自带工具使用 & 内存溢出和死锁问题案例 & GC垃圾回收
1.JVM调优的相关知识,给出了一个demo案例;
2.JVM调优的主要参数;
3.jdk自带的jvm分析工具的使用;
3.内存溢出的调优场景,逐步分析定位问题;
4.发生死锁的分析案例
JVM参数设置
-Xms设置堆的最小空间大小。
-Xmx设置堆的最大空间大小。
-XX:NewSize设置新生代最小空间大小。
-XX:MaxNewSize设置新生代最大空间大小。
-XX:PermSize设置永久代最小空间大小。
-XX:MaxPermSize设置永久代最大空间大小。
-Xss设置每个线程的堆栈大小。
java -XX参数主要有3种:行为参数,调优参数,调试参数
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
行为参数(功能开关) -XX:-DisableExplicitGC 禁止调用System.gc();但jvm的gc仍然有效 -XX:+MaxFDLimit 最大化文件描述符的数量限制 -XX:+ScavengeBeforeFullGC 新生代GC优先于Full GC执行 -XX:+UseGCOverheadLimit 在抛出OOM之前限制jvm耗费在GC上的时间比例 -XX:-UseConcMarkSweepGC 对老年代采用并发标记交换算法进行GC -XX:-UseParallelGC 启用并行GC -XX:-UseParallelOldGC 对Full GC启用并行,当-XX:-UseParallelGC启用时该项自动启用 -XX:-UseSerialGC 启用串行GC -XX:+UseThreadPriorities 启用本地线程优先级 性能调优 -XX:LargePageSizeInBytes=4m 设置用于Java堆的大页面尺寸 -XX:MaxHeapFreeRatio=70 GC后java堆中空闲量占的最大比例 -XX:MaxNewSize=size 新生成对象能占用内存的最大值 -XX:MaxPermSize=64m 老年代对象能占用内存的最大值 -XX:MinHeapFreeRatio=40 GC后java堆中空闲量占的最小比例 -XX:NewRatio=2 新生代内存容量与老生代内存容量的比例 -XX:NewSize=size 新生代对象生成时占用内存的默认值 -XX:ReservedCodeCacheSize=32m 保留代码占用的内存容量 -XX:ThreadStackSize=512 设置线程栈大小,若为0则使用系统默认值 -XX:+UseLargePages 使用大页面内存 调试参数 -XX:-CITime 打印消耗在JIT编译的时间 -XX:ErrorFile=./hs_err_pid<pid>.log 保存错误日志或者数据到文件中 -XX:-ExtendedDTraceProbes 开启solaris特有的dtrace探针 -XX:HeapDumpPath=./java_pid<pid>.hprof 指定导出堆信息时的路径或文件名 -XX:-HeapDumpOnOutOfMemoryError 当首次遭遇OOM时导出此时堆中相关信息 -XX:OnError="<cmd args>;<cmd args>" 出现致命ERROR之后运行自定义命令 -XX:OnOutOfMemoryError="<cmd args>;<cmd args>" 当首次遭遇OOM时执行自定义命令 -XX:-PrintClassHistogram 遇到Ctrl-Break后打印类实例的柱状信息,与jmap -histo功能相同 -XX:-PrintConcurrentLocks 遇到Ctrl-Break后打印并发锁的相关信息,与jstack -l功能相同 -XX:-PrintCommandLineFlags 打印在命令行中出现过的标记 -XX:-PrintCompilation 当一个方法被编译时打印相关信息 -XX:-PrintGC 每次GC时打印相关信息 -XX:-PrintGCDetails 每次GC时打印详细信息 -XX:-PrintGCTimeStamps 打印每次GC的时间戳 -XX:-TraceClassLoading 跟踪类的加载信息 -XX:-TraceClassLoadingPreorder 跟踪被引用到的所有类的加载信息 -XX:-TraceClassResolution 跟踪常量池 -XX:-TraceClassUnloading 跟踪类的卸载信息 -XX:-TraceLoaderConstraints 跟踪类加载器约束的相关信息 |
View Details