I. Daftar Isi
I. Daftar Isi
II. Memory Leak
III. Jenis Memory Leak
IV. Cara Mengatasi
V. Contoh LeakLess Trigger
VI. Variables
II. Memory Leak
Apa itu Memory Leak?
Memory Leak adalah sesuatu yang menambah memory yang digunakan oleh suatu program
ketika kita meng"create" suatu objek. Seperti saat kita membuat Unit, dan lain lain.
(...Kurang ngerti tentang komputer xD)
Hal yang pasti adalah:
1. Memory Leak menyebabkan Lag
2. Memory Leak berlebih dapat menyebabkan Server Split
3. Memory Leak berlebih menyebabkan random disconnect
Wah... serem ya? Karena itu hindarilah Memory Leak...
III. Jenis Memory Leak
Seperti yang sudah dikatakan sebelumnya, Memory Leak muncul saat kita create
suatu objek. Wah, apa saja tuh yang di"create"? Player? Unit? Unit Group?
Nah... ini List untuk yang Leak dan Tidak Leak...
NgeLeak:
1. Special Effect
2. Unit Group
3. Player Group
4. Point
5. Region
6. Floating Text
7. Countdown Timer
8. Timer Dialog
9. Widgets (Mencakup: Unit, Item, dan Destructables)
Masih ada sih, tapi itu yang paling sering keluar :tongue:
Tidak ngeLeak:
1. Player
2. Integer
3. Real
4. String
Ya... semacem string sih leak, tapi mau diapain :confuse:
Masih ada sih, tapi itu yang paling sering ditanya :tongue:
IV. Cara Mengatasi
Cara untuk mengatasi Leak adalah dengan menghancurkan objek tsb setelah kita create DAN SEBELUM KITA OVERWRITE ATAU GANTI :tongue:
Nah... di sini kita ulang lagi bagian apa saja yang leak.
Pertama,
1. Special Effect
Bagaimana cara menanggulangi Leak yang disebabkan oleh Special Effect?
Pada suatu trigger GUI, biasanya kita melakukan ini...
Code:
Special Effect Leak
Events
Conditions
Actions
Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
Nah, ini ngeLeak!
Untuk menghilangkan leaknya, kita hancurkan Special Effect tsb :tongue:
begini cara menghancurkannya:
Code:
Special Effect No Leak
Events
Conditions
Actions
Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
Special Effect - Destroy (Last created special effect)
Tapi...
Itu Special Effectnya langsung hilang... jadi cuma play Death Animation atau main animasinya 1x :tense:
Jadi gimana buat yang tahan lama? :dizzy:
Code:
Special Effect No Leak
Events
Conditions
Actions
Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
Set tempEffect = (Last created special effect)
Wait 5.00 seconds
Special Effect - Destroy tempEffect
dimana tempEffect adalah Variable Special Effect...
Ini tahan 5 detik :tongue:
Tapi...
Ada masalahnya juga!
Variablenya ga bisa dipake sama special effect lain kalo gini :dizzy:
Nah ini tapi masalahnya sama Local Variables...
bukan sama Leak :dizzy:
Jadi lanjut ke yang kedua...
2. Unit Group
Kalau tidak salah kita sering bikin ini kan?
Code:
Unit Group Leak
Events
Conditions
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
Nah, ini ngeLeak :tongue:
Pertama-tama, kita buat jadi Variables duLu... karena kita harus store data Unit Groupnya agar bisa kita destroy sewaktu-waktu :tongue:
Jadi begini...
Code:
Unit Group Leak
Events
Conditions
Actions
Set tempGroup = (Units in (Playable map area))
Unit Group - Pick every unit in tempGroup and do (Actions)
Loop - Actions
Variablenya adalah tempGroup...
Kan udah dijadiin Variable tuh ya...
Sekarang, gimana untuk menghilangkan Leaknya? :dizzy:
Kita harus menghancurkan Unit Group tersebut setelah selesai dipakai :tongue:
Tapi gimana ngancurinnya? Ga ada pilihannya buat ngancurin Unit Group... :dizzy:
Di sini kita akan menggunakan Custom Script!
Kita akan mengambil sebagian function dari JASS... :tongue:
Apa itu JASS? Sesuatu yang pasti sumber bahasa program dari GUI...
Tapi kita di sini bukan untuk JASS, melainkan Memory Leak, jadi... lanjuuut :tongue:
Kita harus menambahkan Custom Script yang ditulis function JASS DestroyGroup...
Hasilnya akan seperti ini:
Code:
Unit Group No Leak
Events
Conditions
Actions
Set tempGroup = (Units in (Playable map area))
Unit Group - Pick every unit in tempGroup and do (Actions)
Loop - Actions
Custom script: call DestroyGroup(udg_tempGroup)
Apaan tuhhhh :dizzy:? @#*@*# ga ngerti
Saat kita menambah Custom Script... kita bisa menulis sesuatu di situ...
tuLislah "call DestroyGroup(udg_VARIABLEUNITGROUP)"
dan ingatlah kalau ini CASE SENSITIVE :tongue:
Oh... tapi udg_ apaan?
udg = User Defined Global, pasti ada untuk semua Global Variable...
Jadi gitu saja kira-kira... :tongue:
Unit Group sudah tidak ngeLeak! :tongue:
Panjang ya? Tapi itu baru yang kedua... :dizzy:
3. Player Group
Ya... ga beda jauh sama Unit Group :tongue:
Jadi kaLau sudah ngerti Unit Group, yang ini ga bakal susah...
Dimulai dari yang masih ngeLeak,
Code:
Player Group Leak
Events
Conditions
Actions
Player Group - Pick every player in (All players controlled by a Computer player) and do (Actions)
Loop - Actions
Nah itu ngeLeak...
Pertama set jadi Variable duLu...
Code:
Player Group Leak
Events
Conditions
Actions
Set tempForce = (All players controlled by a Computer player)
Player Group - Pick every player in tempForce and do (Actions)
Loop - Actions
tempForce adalah variable Player Group...
Nah... di sini kita kasih Custom Script lagi...
Kita harus menambahkan Custom Script yang ditulis function JASS DestroyForce...
Begini jadinya :tongue: ...
Code:
Player Group No Leak
Events
Conditions
Actions
Set tempForce = (All players controlled by a Computer player)
Player Group - Pick every player in tempForce and do (Actions)
Loop - Actions
Custom script: call DestroyForce(udg_tempForce)
Dah ga ngeLeak kan :tongue:
Pendek kan :tongue:
sekarang, yang ke-empat...
4. Point
Ini juga sering ada kan:
Code:
Point Leak
Events
Conditions
Actions
Unit - Move (Triggering unit) instantly to (Center of (Playable map area))
Seperti biasa, ubah jadi variable duLu...
Code:
Point Leak
Events
Conditions
Actions
Set tempPoint = (Center of (Playable map area))
Unit - Move (Triggering unit) instantly to tempPoint
tempPoint adalah variable point...
Nah, kali ini kita pakai Custom Script juga...
functionnya kali ini adalah: RemoveLocation
Code:
Point No Leak
Events
Conditions
Actions
Set tempPoint = (Center of (Playable map area))
Unit - Move (Triggering unit) instantly to tempPoint
Custom script: call RemoveLocation(udg_tempPoint)
Ini juga sudah tidak ngeLeak :tongue:
Simple kan?
Lanjut ke yang ke-lima...
5. Region
Untuk yang kali ini...
Akan dipadukan beberapa bagian yang lain...
Begini contoh yang ngeLeaknya:
Code:
Region Leak
Events
Conditions
Actions
Set tempPoint = (Position of (Triggering unit))
Set tempGroup = (Units in (Region centered at tempPoint with size (500.00, 500.00)))
Unit Group - Pick every unit in tempGroup and do (Actions)
Loop - Actions
Custom script: call RemoveLocation(udg_tempPoint)
Custom script: call DestroyGroup(udg_tempGroup)
Nah di situ ada leak Region...
saat tempGroup sedang di set...
kita membuat sesuatu tapi tidak ingat untuk menghancurkannya...
untuk menghancurkannya... harus jadi variable duLu...
Code:
Region Leak
Events
Conditions
Actions
Set tempPoint = (Position of (Triggering unit))
Set tempRegion = (Region centered at tempPoint with size (500.00, 500.00))
Set tempGroup = (Units in tempRegion)
Unit Group - Pick every unit in tempGroup and do (Actions)
Loop - Actions
Custom script: call RemoveLocation(udg_tempPoint)
Custom script: call DestroyGroup(udg_tempGroup)
Di sini juga Custom Script :dizzy:
functionnya: RemoveRect
Code:
Region No Leak
Events
Conditions
Actions
Set tempPoint = (Position of (Triggering unit))
Set tempRegion = (Region centered at tempPoint with size (500.00, 500.00))
Set tempGroup = (Units in tempRegion)
Unit Group - Pick every unit in tempGroup and do (Actions)
Loop - Actions
Custom script: call RemoveLocation(udg_tempPoint)
Custom script: call RemoveRect(udg_tempRegion)
Custom script: call DestroyGroup(udg_tempGroup)
6. Floating Text
Aa...
Untuk Floating Text, Countdown Timer, dan Timer Dialog...
Kayaknya gampang kan udah ada pilihannya di GUI :dizzy:
jadi kelihatannya ga perlu dijelasin...
setelah dipakai, tinggal diDestroy...
9. Widgets
Untuk Unit, Item, dan Destructables...
Cara menghilangkan Leaknya adalah dengan meRemovenya... bukan kill...
Tapi biasanya kita ga akan ngeRemove kan :dizzy:
karena biasanya kita butuh sampai game seLesai... :tongue:
V. Contoh LeakLess Trigger
Code:
Good LeakLess Trigger
Events
Unit - A unit Is attacked
Conditions
(Triggering unit) Equal to UnitYangSangatIMBA
Actions
Set tempUnit = (Attacking unit)
Wait 5.00 seconds
Set tempPoint = (Position of tempUnit)
Set tempRegion = (Region centered at tempPoint with size (256.00, 256.00))
Set tempGroup = (Units in tempRegion)
Unit Group - Pick every unit in tempGroup and do (Actions)
Loop - Actions
Unit - Kill (Picked unit)
Custom script: call RemoveRect(udg_tempRegion)
Custom script: call DestroyGroup(udg_tempGroup)
Set tempRegion = (Region centered at tempPoint with size (96.00, 96.00))
Set tempGroup = (Units in tempRegion)
Unit Group - Pick every unit in tempGroup and do (Actions)
Loop - Actions
Unit - Remove (Picked unit) from the game
Custom script: call RemoveLocation(udg_tempPoint)
Custom script: call RemoveRect(udg_tempRegion)
Custom script: call DestroyGroup(udg_tempGroup)
VI. Variables
Variable tidak menghilangkan Leak atau apapun.
Variable hanya membantu kita untuk memberi nama pada suatu objek,
dimana jika sembarang ngeCreate objek, kita tidak tahu namanya dan alhasil kita tidak bisa menghancurkannya
Masih mungkin setelah kita create langsung dihancurkan, dan itu tidak menghasilkan Leak.
Jadi, Variable hanya bersifat membantu, dan penghilangan leak ada pada hancurnya objek.
Beberapa guna Variable:
1. Mempercepat peng-eksekusian Action.
Misal kita membutuhkan "Event Response - Attacking Unit" lebih dari satu kali,
Alangkah baiknya jika diSet jadi Variable duLu...
2. Data Storing
Kita bita menyimpan unit "Event Response - Attacking Unit", mengingat jika kita gunakan Action Wait atau sejenisnya,
"Event Response - Attacking Unit" sudah tidak berlaku.
Jadi di awal trigger sebelum ada wait dan sejenisnya kita set jadi Variable dan setelah wait kita bisa gunakan Variable tsb
menggantikan "Event Response - Attacking Unit" :tongue:
Hanya sekilas info tentang Variable :dizzy:
***END OF TUTORIAL***
Thx for ur time spent with this Tutorial :tongue:
Mungkin masih banyak kekurangan, tapi ntar bakal diupdate deh :dizzy:
Gw masih agak nubi :dizzy:
Pertanyaan reply di bawah aja :tongue:
Share This Thread