我正在写一个游戏,当我尝试向服务器发送聊天消息时,我得到一个奇怪的内存泄漏.发送字符串:!chat¥Test变为:
!chat¥test
!chat¥!chat¥test
!chat¥!chat¥!chat¥test
!chat¥!chat¥!chat¥!chat¥test
!chat¥!chat¥!chat¥!chat¥!chat¥test
!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥test
!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥test
!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥test
!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥test
!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥test
!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥!chat¥test
Ect, ect.
Sending message:
Utils.sendChat(message.getText());
public static void sendChat(String s) {
System.out.println(s);
sendChat("!chat"+Wrapper.commandSplit+s);
}
public static void sendTextLine(String s){
s = s.replace(" ", "[SPACE]");
System.out.println(s);
Wrapper.pw.write(s);
Wrapper.pw.flush();
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会这样,有人能帮帮我吗?我使用'¥'来分割字符串中的变量,之前没有给我任何问题,所以我怀疑它与它有什么关系.
谢谢.
Aff*_*ffe 10
public static void sendChat(String s) {
System.out.println(s);
sendChat("!chat"+Wrapper.commandSplit+s);
}
Run Code Online (Sandbox Code Playgroud)
这是一个无限循环,每次你sendChat再次打电话时建立更长更长的琴弦.
你可能打算sendTextLine在那里打电话给第二行?
| 归档时间: |
|
| 查看次数: |
92 次 |
| 最近记录: |