找回密码
 点一下
楼主: zyl910

GetSpellTargetLoc返回的点该不该释放 (已解决)

[复制链接]
发表于 2006-3-31 20:45:34 | 显示全部楼层
于是本帖子名至实归的去了JASS区

名至实归应该米用错
回复

使用道具 举报

发表于 2006-3-31 20:47:43 | 显示全部楼层
原帖由 zyl910 于 2006-3-31 20:45 发表


的确
我一直想找到释放string的函数



set XXX=\"\"
回复

使用道具 举报

发表于 2006-3-31 20:50:08 | 显示全部楼层
说实话
我一直对WE中String滴内存表示以及是否会自动释放以及释放时间存在疑问...
我曾经在一个函数里把String转成Int,然后在另一个函数里把那个Int转成String,发现仍然可以用...
回复

使用道具 举报

 楼主| 发表于 2006-3-31 21:11:50 | 显示全部楼层
释放string没那么简单滴

注意看这个触发器:

  1. TestString
  2.     事件
  3.         Player - 玩家 1 (红色) skips a cinematic sequence
  4.     环境
  5.     动作
  6.         Custom script: local string sTemp = ""
  7.         Custom script: set udg_iTemp = Str2I(sTemp)
  8.         Game - Display to (All players) the text: (String Inited:  + (String(iTemp)))
  9.         Custom script: set sTemp = "123"
  10.         Custom script: set udg_iTemp = Str2I(sTemp)
  11.         Game - Display to (All players) the text: (String 1:  + (String(iTemp)))
  12.         Custom script: set sTemp = sTemp + "ABC"
  13.         Custom script: set udg_iTemp = Str2I(sTemp)
  14.         Game - Display to (All players) the text: (String 2:  + (String(iTemp)))
  15.         Custom script: set sTemp = ""
  16.         Custom script: set udg_iTemp = Str2I(sTemp)
  17.         Game - Display to (All players) the text: (String null:  + (String(iTemp)))
复制代码



其结果永远为:
String Inited: 1
String 1: 24
String 2: 29
String null: 1


我是指“String 1”、“String 2”的值是不会变的
这表示每次进行字符串操作时,WC3都会存储字符串数据
当将string变量设为\"\"时,字符串数据并没有释放
回复

使用道具 举报

 楼主| 发表于 2006-3-31 21:16:30 | 显示全部楼层
现在大概有点明白为什么AI中不能用string了:
这是因为WC3会自动保存string的字符串数据
而编AI一般用多线程的
所以会出现线程同步问题
回复

使用道具 举报

发表于 2006-3-31 21:20:21 | 显示全部楼层
设为空这样已经是能做到的极致了。
回复

使用道具 举报

 楼主| 发表于 2006-3-31 21:28:27 | 显示全部楼层
看来string才是最终BOSS
除了将其无视外(设为\"\"),没办法
回复

使用道具 举报

发表于 2006-4-1 02:10:57 | 显示全部楼层
原来被移动了~~~~
回复

使用道具 举报

 楼主| 发表于 2006-4-3 21:11:16 | 显示全部楼层
原帖由 誓言如风 于 2006-4-3 16:46 发表
能把这关于地图优化的资料集合起来吗?



正在研究中啊……

100多种数据类型
累死人了
回复

使用道具 举报

发表于 2006-4-4 01:34:41 | 显示全部楼层
set string_temp = null
回复

使用道具 举报

发表于 2006-4-16 00:41:27 | 显示全部楼层
设定为null怎么可能实现释放内存呢?
回复

使用道具 举报

发表于 2006-4-16 00:46:14 | 显示全部楼层
原帖由 zyl910 于 2006-3-31 20:45 发表


的确
我一直想找到释放string的函数


string所占用的内存应该是不能释放的。因为它不是动态申请的。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-5-2 21:28 , Processed in 0.081383 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表