类型,对象,线程栈和托管堆在运行时的相互关系
当系统加载一个CLR的进程,进程里面可能有多个线程,这时候系统会给这个进程创建一个大小为1M的线程栈。这个线程栈用来存放方法调用的实参,和方法内部定义的局部变量。下图展示了一个线程栈的栈内存。线程栈的存储是从高位内存地址向地位内存地址构建的。现在假设线程栈执行的代码要调用M1方法。
在这个很简单的方法中,应该包含一些初始化这个方法的“序幕”代码,和一些“尾声”代码,负责在方法调用完成之后对方法进行清理。然后才返回给这个方法的调用者。M1方法调用开始时,M1的序幕代码在线程栈上分配局部变量name的内存。如下图
然后M1调用M2方法,将name作为一个实参来传递。这造成name局部变量中的地址被压入栈。如下图:在M2方法内部,将使用名为s的参数变量来表示栈位置。另外调用一个方法时还要将一个返回地址压入栈。被调用的方法结束后,应该返回到这个位置。如下图:M1调用M2的时候将实参和返回地址压入栈。
M2方法开始执行时,同样它的“序幕”代码在线程栈中为局部变量length和tally分配内存。如下图,然后M2中的内部代码开始执行。最终方法内部的代码开始执行,最终到达return语句,此时CPU的指令指针被设置成线程栈中的返回地址。而且M2的栈帧会被展开。 (我理解栈帧被展开的意思就是在线程栈中就M2方法的痕迹给消除,应该是被尾声代码所为),这点不是很理解,肯定不能是在清楚M2方法法的痕迹之后在返回,那样返回地址已经不存在了,那就是程序在返回给调用者之后猜进行清理的?请教牛人。 ,之后M1会执行M2方法调用后面的代码。最后M1会同M2一样返回给调用者。
参考clr via C#
说的不对的地方,口下留情,疑惑地方请指点。
今日闲来无事,改写一套博客园皮肤,效果看本人空间,欢迎使用!
1 /* --------------http://zhaozi.cnblogs.com--------------- */ 2 #EntryTag { font-size : 9pt ;} 3 #divRefreshComments { text-align : right ; margin-right : 10px ; margin-bottom : 5px ; font-size : 9pt ;} 4 .topicListFooter { text-align : right ; margin-right : 10px ; margin-top : 10px ;} 5 * { margin : 0 ; padding : 0 ;} 6 body { margin : 0 ; padding : 0 ; color : #333 ; background-color : #EAEAEA ; font-family : '微软雅黑',verdana,arial ; font-size : 12px ; line-height : 1.5 ;} 7 img { border : 0 ;} 8 li { list-style : none ;} 9 input,textarea { border : 1px solid #BBB ;} 10 h1,h2,h3,h4,h5,h6,th { font-weight : bold ; color : #000 ;} 11 a { text-decoration : none ; color : #333 ;} 12 a:hover { color : #F60 ;} 13 #cnliu_header {} 14 .cnliu_ad_sidebar { margin-top : 10px ; margin-bottom : 10px ; width : 300px ; height : 0 ; overflow : hidden ;} 15 #cnliu_footer { margin-left : 30px ; padding-left : 35px ; width : 725px ; font-size : 12px ; text-align : left ; line-height : 150% ;} 16 #cnliu_footer a { color : #BBB ;} 17 #mainContent { margin-left : 15px ; border-left : 1px solid #DDD ; border-right : 1px solid #DDD ; border-bottom : 1px solid #DDD ; width : 760px ; padding-top : 25px ; padding-bottom : 30px ; background-color : #FFF ; float : left } 18 /* right */ 19 #sideBar { width : 270px ; border-top-width : 0 ; overflow : hidden ; padding : 0 0 20px 10px ;} 20 .forFlow { margin : 0 20px ;} 21 #footer { margin-left : 30px ; margin-top : 30px ; padding-left : 35px ; padding-bottom : 5px ; text-align : left ; display : none } 22 #lnkBlogLogo { display : none ;} 23 #blogTitle { padding : 16px 20px ;} 24 #blogTitle h1 { font-size : 24px ;} 25 #blogTitle h2 { font-size : 10.5pt ; color : #999 ;} 26 #blogTitle .title { font-size : 24px ;} 27 #blogTitle .subtitle { font-size : 10.5pt ; color : #999 ;} 28 #navigator { margin-left : 15px ; border-left : 1px solid #DDD ; border-right : 1px solid #DDD ; width : 975px ; background : #f6f6f6 ; border-top : 1px solid #DDD ; border-bottom : 1px solid #DDD ; border-width : 1px ; height : 30px ; line-height : 30px ; color : #999 ; padding-left : 30px ; padding-right : 35px ; padding-top : 2px ;} 29 #navigator img { display : none ;} 30 .blogStats { float : right ; color : #999 ;} 31 #navList li { float : left ; margin-right : 20px ; font-size : 10.5pt ; font-weight : bold } 32 #sideBar li,.divRecentCommentAticle { text-indent : -1.5em ; margin-left : 1.5em ;} 33 #sideBar h3,#MyIng .ing_title { margin : 16px 0 0 0px ; font-size : 14px ; text-align : left ;} 34 #calendar { margin-top : 16px ; text-align : center ;} 35 #calendar table { width : 90% ; margin : 0 auto ;} 36 #calendar .CalOtherMonthDay { color : #999 ;} 37 #sideBar .divRecentComment { color : #666 ; margin : 0 0 8px 8px ;} 38 #sideBar .recent_comment_body { color : #666 ; margin : 5px 0 8px 18px ; text-indent : 0px ;} 39 #sideBar a { color : #06C ;} 40 #sideBar a:hover { color : #17A8FA ;} 41 .ing_title a:link,.ing_title a:visited,.ing_title a:hover,.ing_title a:active { 42 font-weight : bold ; 43 } 44 div.commentform textarea { width : 450px ; height : 300px ; ont-size : 13px ;} 45 46 /* --------------http://zhaozi.cnblogs.com--------------- */ 47 .dayTitle { display : none ;} 48 .entrylistTitle,.thumbTitle,.PostListTitle,.forFlow h3 div,.galleryTitle { font-size : 14px ; font-weight : bold ; margin-top : 20px ; text-align : left ;} 49 .entrylistDescription,.thumbDescription { margin-left : 16px ;} 50 .postTitle,.entrylistPosttitle,.feedback_area_title { border-bottom : 1px solid #ddd ; font-family : '宋体','微软雅黑' ; font-size : 14px ; font-weight : bold ; margin : 20px 0 10px ;} 51 .postBody { color : #111 ; font-size : 13px ; line-height : 170% ;} 52 .postBody span { color : #111 ; font-size : 13px ; line-height : 1.5 ;} 53 .postBody h5 { font-size : 10pt } 54 .postBody p,.postCon p { margin : 12px auto ;} 55 .postCon { overflow : hidden ; font-size : 13px ;} 56 .c_b_p_desc { line-height : 170% ;} 57 .postCon a,.postBody a,.feedbackCon a { text-decoration : underline ; color : #0066cc ;} 58 .postCon a:hover,.postBody a:hover,.feedbackCon a:hover { border-color : #999 ;} 59 .postDesc,.entrylistItemPostDesc { border-bottom : 0px dotted #999 ; color : #666 ; text-align : right ; padding-bottom : 5px ; vertical-align : middle ;} 60 .postDesc a:link,.postDesc a:active,.postDesc a:visited { color : #666 ; text-decoration : none ;} 61 .postDesc a:hover { text-decoration : underline ;} 62 .PostList { float : none ; clear : both ; text-align : right ; width : 96% ; margin : auto ; padding : 6px 0 ; overflow : hidden ; border-bottom : 1px dotted #ccc ;} 63 .postTitl2 { float : left ;} 64 .postText2 { text-align : left ; color : #666 ;} 65 .feedbackItem { padding : 8px ; border-bottom : 1px dotted #ccc ;} 66 .feedbackManage { float : right ;} 67 .feedbackCon { margin-left : 1em ; color : #666 ; line-height : 1.5 ;} 68 .commentform td div span { margin-left : 12px ;} 69 .gallery img { margin : 8px ;} 70 #taglist { margin : 20px auto ;} 71 .pfl_feedback_area_title { font-size : 16px ; margin : 16px 0 ; font-weight : bold ;} 72 .pfl_feedback_area_title a { font-size : 12px ; color : #999 ; font-weight : normal ;} 73 .pfl_feedbacksubtitle { height : 30px ;} 74 .pfl_feedbackname,.pfl_feedbackManage { float : left ; margin : 10px 20px 0 0 ;} 75 .pfl_feedbackCon,.pfl_feedbackAnswer { clear : both ; margin-left : 12px ;} 76 .btn_my_zzk { border : 0px ;} 77 #sideBarMain { padding-left : 0px ;} 78 #MyIng { padding-left : 10px ;} 79 div#sideBar div#side_ing_block ul li { margin-left : 0px ; text-indent : 0px ;} 80 #side_ing_block { line-height : 180% ;} 81 #EntryTag { margin-top : 10px ;} 82 #blog_ad_google h3 { margin-bottom : 10px ;} 83 #digg_block a:link,#digg_block a:visited,#digg_block a:active { color : #015FB6 ; } 84 #digg_block { color : #015FB6 ;} 85 span.diggnum { color : #015FB6 ;} 86 span.burynum { color : #015FB6 ;} 87 #sideBarMain { border : 1px solid #ddd ; padding-left : 5px ; background-color : #FFFFFF ; padding-bottom : 20px ; margin-top : -1px ;} 88 .post { overflow : hidden } 89 .c_ad_block,.ad_text_commentbox,#site_nav_under { display : none ;} 90 .zhaozifooter { text-align : center ; padding : 10px ; width : 1028px ; height : auto ; border : 1px solid #DDD ; background-color : #FFFFFF ; margin-left : auto ; margin-right : auto ; margin-top : 10px ;} 91 .postTitle a { color : #1A64A2 ; background-image : url(http://kb.cnblogs.com/images/icons/arrow.png) ; background-repeat : no-repeat ; background-position : left ; padding-left : 18px } 92 .postTitle a:hover { color : #F60 } 93 .mySearch { display : none } 94 #ad_under_google { display : none ; overflow : hidden ; width : 0 ; height : 0 ; color : #FFFFFF ;} 95 .title { FILTER : blur(direction=135,strength=8) ; font-weight : bold } 96 .subtitle { FILTER : mask(color=#E1E4EC) 97 shadow(color=#8C96B5,direction=135)chroma(color=#E1E4EC) 98 } 99 body { text-align : center } 100 body * { text-align : left } 101 #home { margin-left : auto ; margin-right : auto ; width : 1080px ;} 102 /* --------------http://zhaozi.cnblogs.com--------------- */
分类: Web
标签: css
ASP.NET
Enterprise Data Access Application
摘要: •Reference the Data Access block assemblies• Configure Data Access settings• Add the required Namespace• Create an instance of Database• Perform actions using the Database instance(1) includingMicrosoft.Practices.EnterpriseLibrary.Common.dll RequiredMicrosoft.Practices.Unity.dll RequiredMicrosoft.Pr 阅读全文
posted @ 2011-06-16 16:58 天添 阅读(37) | 评论 (0) 编辑
Delegate
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace DelegateAndEvent{ public delegate void nDelegate(); public delegate void sDelegate(string str); public delegate void mulDelegate(string str); class Program { public delegate void eventDelegate(string str); pu 阅读全文
posted @ 2011-06-14 19:03 天添 阅读(5) | 评论 (0) 编辑
当前访问人数
摘要: Application.lock();if(Application["count"] == null){ Application["count"] = 1;}else{ Application["count"] += 1;}Application.unlock(); 阅读全文
posted @ 2011-06-10 17:44 天添 阅读(8) | 评论 (0) 编辑
jQuery
摘要: function analyse(currentOperator,seriesName) { var url= "Analyse.aspx?CurrentOperator="+currentOperator+"&SeriesName="+seriesName; $('#dialog').empty(); var div = $('#dialog').append("<iframe frameborder=0 align=center src="+url+" scrolling=& 阅读全文
posted @ 2011-06-01 17:58 天添 阅读(2) | 评论 (0) 编辑
数据Excel方式下载
摘要: public void CreateExcel(DataTable dt, string FileName, int pageSize, int pageNum) { HttpResponse resp; resp = Page.Response; resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); resp.ContentType = "application/ms-excel"; resp.AddHeader("Content-Disposition" 阅读全文
posted @ 2011-04-08 17:08 天添 阅读(10) | 评论 (0) 编辑
作者: Leo_wl
出处: http://www.cnblogs.com/Leo_wl/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
版权信息查看更多关于类型,对象,线程栈和托管堆在运行时的相互关系的详细内容...