נו באמת,

אלדד26

New member
נו באמת,

כל כך הרבה אנשים חכמים ואף אחד לא יודע את התשובה? מחזיר אתכם לשאלה ששאלתי במקום הזה. שאלה בעניין GLUT. מישהו?
 

gew

New member
Answer

The OS frees the memory you allocated when your program exits. gew.
 

אלדד26

New member
זה פתרון "מלוכלך".

וחוץ מזה, מה אם יש לי resources אחרים, שלאו דווקא משתחררים עם ה - process? או יותר גרוע. נניח שיש לי process שמריץ כמה threads, שכל אחד מהם עושה איזושהי פעילות ובסוף נכנס ל - glutMainLoop. גם אם תוריד את ה - thread מבחוץ בכוח, ה - resources לא ישתחררו עד שלא תצא מה - process. יש פתרונות לעניין הזה, אבל הם מאוד לא אלגנטיים. למשל, אם רץ thread מסוים, והוא פתח שני קבצים והקצה 1 מגהבייט של זיכרון, אז אפשר - לפני שיוצאים מה - thread - לקרוא לפונקציה שתדליק דגל שיגרום ל - thread להפסיק להשתמש בקבצים ובשטח הזיכרון הזה, ואז להוריד את ההקצאות - ואז להוריד את ה - thread. אבל אז, כל מה שאמרתי כאן מתבצע בעצם מחוץ ל - thread ולא בתוכו... וזה עקום.
 

gew

New member
Well,

You asked what happens when the program exits and what happens is that the OS frees the allocated memory (If that´s a good OS, that is.) What I understand is that using the "Close" option of your application makes main() return (that since you said that no code ever executes after glutMainLoop) I may have misunderstood your question You should read the specifications of the threads package you´re using to see whether or not memory allocated by a thread is freed automatically when it (the thread) is being killed.
 
למעלה