Tags:

ผมต้องการดึงข้อมูลใหม่ๆมาแสดงบนหน้าเว็บเรื่อยๆ ทุกๆ5วิ

ผม set interval แล้ว ajax ข้อมูลมาเรื่อยๆ

รู้สึกว่า memory มันค่อยๆเยอะขึ้น

อยากได้วิธีเคลีย memory อะครับ

หรือมีวิธีอื่นที่ดีกว่านี้มั้ยครับ

Get latest news from Blognone
By: osmiumwo1f
ContributorWindows PhoneWindows
on 15 October 2015 - 10:51 #852930
osmiumwo1f's picture

ให้ทำลาย reference ของ object หรือตัวแปร โดยการตั้งค่าให้เป็น undefined หรือ null หรือ "" แล้ว garbage collector จะจัดการเอาออกเองครับ
ปล. ตั้งค่าเป็น null จะดีกว่าครับ

By: rattananen
AndroidWindows
on 15 October 2015 - 10:19 #852983

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management

http://docstore.mik.ua/orelly/webprog/jscript/ch11_03.htm

http://www.ibm.com/developerworks/web/library/wa-memleak/

By: first100
Windows PhoneWindows
on 15 October 2015 - 18:31 #853114
first100's picture

ขอบคุณครับ
แต่ผมไม่ใช้ ajax แล้ว
ผมเปลี่ยนไปใช้ server side event แทนแล้วครับ

By: platezero on 17 October 2015 - 10:10 #853465 Reply to:853114

Server-Sent Events หรือปล่าวครับ ถ้างานที่ทำอยู่จำเป็นต้องรองรับ Browser รุ่นเก่าๆ อย่าลืมดูเรื่อง Browser Compatible ด้วยนะครับ

By: first100
Windows PhoneWindows
on 26 October 2015 - 19:44 #856239 Reply to:853465
first100's picture

ใช่ครับ Server-Sent Events

ตอนนี้มีอีกปัญหานึงครับ
ผมเอาไปวางไว้ที่ IIS บน Windows Server 2012
มันดีเลย์ 5 นาที
5 นาทีโหลดที
ไม่ทราบเป็นเพราะอะไร พอจะรู้มั้ยครับ

By: rattananen
AndroidWindows
on 27 October 2015 - 15:01 #856466 Reply to:853465

ไม่ต้องห่วงเรื่อง browser รุ่นเก่าๆ เลยครับ
browser ของ MS ไม่รองรับทุก version
http://caniuse.com/#search=Server-Sent%20Events