{"id":38112,"date":"2024-07-12T06:53:49","date_gmt":"2024-07-12T04:53:49","guid":{"rendered":"https:\/\/www.techopedia.com\/es\/?post_type=definition&p=38112"},"modified":"2024-07-12T10:03:44","modified_gmt":"2024-07-12T08:03:44","slug":"finalizar","status":"publish","type":"definition","link":"https:\/\/www.techopedia.com\/es\/definicion\/finalizar","title":{"rendered":"Finalizar"},"content":{"rendered":"

\u00bfQu\u00e9 significa finalizar?<\/span><\/h2>\n

Finalizar es un m\u00e9todo de objeto que contiene el c\u00f3digo necesario para liberar recursos no gestionados y realizar operaciones de limpieza antes de la recogida de basura (GC).<\/p>\n

El m\u00e9todo finalizar se utiliza para limpiar recursos no gestionados por .NET<\/strong>. Aunque el marco .NET est\u00e1 dise\u00f1ado para liberar recursos gestionados realizando impl\u00edcitamente tareas de gesti\u00f3n de memoria, los recursos no gestionados de la aplicaci\u00f3n -como los manejadores de archivos y las conexiones a bases de datos<\/a>– deben liberarse expl\u00edcitamente.<\/p>\n

Definici\u00f3n de finalizar<\/span><\/h2>\n

Mientras que finalizar est\u00e1 dise\u00f1ado para ser llamado impl\u00edcitamente por GC, el m\u00e9todo dispose puede ser llamado expl\u00edcitamente por el c\u00f3digo de usuario para liberar recursos.<\/p>\n

Finalizar es similar a los destructores tradicionales de C++, ya que cada uno es responsable de liberar los recursos del objeto. Los destructores C++ se ejecutan inmediatamente cuando un objeto sale del \u00e1mbito, mientras que finalizar se llama durante la limpieza del objeto en GC.<\/strong><\/p>\n

En C#, finalizar no puede invocarse directamente ni anularse. Si se declara un destructor, se convierte en el m\u00e9todo finalizar cuando se compila el programa.<\/p>\n

Durante la finalizaci\u00f3n, debe evitarse la asignaci\u00f3n de memoria o la llamada a m\u00e9todos virtuales<\/strong>. El \u00e1mbito de finalize debe estar protegido para que s\u00f3lo se pueda acceder a \u00e9l dentro de la misma clase o de su clase derivada.<\/p>\n

Finalizar no debe hacer referencia a ning\u00fan otro objeto. En C#, llamar a finalizar directamente a un objeto que no sea su clase base es una operaci\u00f3n inv\u00e1lida. El c\u00f3digo de finalizaci\u00f3n debe ser m\u00ednimo, sin llamadas capaces de bloquear el subproceso de llamada.<\/p>\n

Como la llamada a finalizar la realiza un subproceso dedicado, su c\u00f3digo no debe utilizar almacenamiento local de subprocesos ni ninguna t\u00e9cnica que requiera afinidad de subprocesos.<\/p>\n

Es esencial utilizar finalizar como mecanismo alternativo para liberar memoria<\/strong> o recursos no gestionados, debido a la falta de determinismo y a los efectos sobre el rendimiento de la GC.<\/p>\n","protected":false},"excerpt":{"rendered":"

\u00bfQu\u00e9 significa finalizar? Finalizar es un m\u00e9todo de objeto que contiene el c\u00f3digo necesario para liberar recursos no gestionados y realizar operaciones de limpieza antes de la recogida de basura (GC). El m\u00e9todo finalizar se utiliza para limpiar recursos no gestionados por .NET. Aunque el marco .NET est\u00e1 dise\u00f1ado para liberar recursos gestionados realizando impl\u00edcitamente […]<\/p>\n","protected":false},"author":7813,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"definitioncat":[888],"class_list":["post-38112","definition","type-definition","status-publish","format-standard","hentry","definitioncat-desarrollo-de-software"],"acf":[],"yoast_head":"\n\u00bfCu\u00e1l es el objetivo de finalizar en programaci\u00f3n?<\/title>\n<meta name=\"description\" content=\"En t\u00e9rminos de programaci\u00f3n el evento finalizar tiene una funci\u00f3n importante en el \u00e1rea de limpieza de un dispositivo, te la explicamos.\" \/>\n<meta name=\"robots\" content=\"noindex, follow\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Finalizar\" \/>\n<meta property=\"og:description\" content=\"En t\u00e9rminos de programaci\u00f3n el evento finalizar tiene una funci\u00f3n importante en el \u00e1rea de limpieza de un dispositivo, te la explicamos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar\" \/>\n<meta property=\"og:site_name\" content=\"Techopedia Espa\u00f1ol\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-12T08:03:44+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar\"},\"author\":{\"name\":\"Margaret Rouse\",\"@id\":\"https:\/\/www.techopedia.com\/es\/#\/schema\/person\/f5dd538e31ee352d105b8af36c4268a5\"},\"headline\":\"Finalizar\",\"datePublished\":\"2024-07-12T04:53:49+00:00\",\"dateModified\":\"2024-07-12T08:03:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar\"},\"wordCount\":350,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.techopedia.com\/es\/#organization\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar\",\"url\":\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar\",\"name\":\"\u00bfCu\u00e1l es el objetivo de finalizar en programaci\u00f3n?\",\"isPartOf\":{\"@id\":\"https:\/\/www.techopedia.com\/es\/#website\"},\"datePublished\":\"2024-07-12T04:53:49+00:00\",\"dateModified\":\"2024-07-12T08:03:44+00:00\",\"description\":\"En t\u00e9rminos de programaci\u00f3n el evento finalizar tiene una funci\u00f3n importante en el \u00e1rea de limpieza de un dispositivo, te la explicamos.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.techopedia.com\/es\/definicion\/finalizar#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Inicio\",\"item\":\"https:\/\/www.techopedia.com\/es\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Term\",\"item\":\"https:\/\/www.techopedia.com\/es\/definicion\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Finalizar\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.techopedia.com\/es\/#website\",\"url\":\"https:\/\/www.techopedia.com\/es\/\",\"name\":\"Techopedia\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.techopedia.com\/es\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.techopedia.com\/es\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.techopedia.com\/es\/#organization\",\"name\":\"Techopedia en Espa\u00f1ol\",\"url\":\"https:\/\/www.techopedia.com\/es\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/www.techopedia.com\/es\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.techopedia.com\/es\/wp-content\/uploads\/sites\/4\/2025\/02\/techopedia-light-logo.svg\",\"contentUrl\":\"https:\/\/www.techopedia.com\/es\/wp-content\/uploads\/sites\/4\/2025\/02\/techopedia-light-logo.svg\",\"caption\":\"Techopedia en Espa\u00f1ol\"},\"image\":{\"@id\":\"https:\/\/www.techopedia.com\/es\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.techopedia.com\/es\/#\/schema\/person\/f5dd538e31ee352d105b8af36c4268a5\",\"name\":\"Margaret Rouse\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/www.techopedia.com\/es\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.techopedia.com\/wp-content\/uploads\/2023\/02\/margaret-rouse-headshot.jpeg\",\"contentUrl\":\"https:\/\/www.techopedia.com\/wp-content\/uploads\/2023\/02\/margaret-rouse-headshot.jpeg\",\"caption\":\"Margaret Rouse\"},\"description\":\"Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret's idea of a fun day is helping IT and business professionals learn to speak each other\u2019s highly specialized languages.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/margaretrouse\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/@techdefinitions\"],\"knowsAbout\":[\"Technology Expert\"],\"url\":\"https:\/\/www.techopedia.com\/es\/autor\/margaret-rouse\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u00bfCu\u00e1l es el objetivo de finalizar en programaci\u00f3n?","description":"En t\u00e9rminos de programaci\u00f3n el evento finalizar tiene una funci\u00f3n importante en el \u00e1rea de limpieza de un dispositivo, te la explicamos.","robots":{"index":"noindex","follow":"follow"},"og_locale":"es_ES","og_type":"article","og_title":"Finalizar","og_description":"En t\u00e9rminos de programaci\u00f3n el evento finalizar tiene una funci\u00f3n importante en el \u00e1rea de limpieza de un dispositivo, te la explicamos.","og_url":"https:\/\/www.techopedia.com\/es\/definicion\/finalizar","og_site_name":"Techopedia Espa\u00f1ol","article_modified_time":"2024-07-12T08:03:44+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.techopedia.com\/es\/definicion\/finalizar#article","isPartOf":{"@id":"https:\/\/www.techopedia.com\/es\/definicion\/finalizar"},"author":{"name":"Margaret Rouse","@id":"https:\/\/www.techopedia.com\/es\/#\/schema\/person\/f5dd538e31ee352d105b8af36c4268a5"},"headline":"Finalizar","datePublished":"2024-07-12T04:53:49+00:00","dateModified":"2024-07-12T08:03:44+00:00","mainEntityOfPage":{"@id":"https:\/\/www.techopedia.com\/es\/definicion\/finalizar"},"wordCount":350,"commentCount":0,"publisher":{"@id":"https:\/\/www.techopedia.com\/es\/#organization"},"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.techopedia.com\/es\/definicion\/finalizar#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.techopedia.com\/es\/definicion\/finalizar","url":"https:\/\/www.techopedia.com\/es\/definicion\/finalizar","name":"\u00bfCu\u00e1l es el objetivo de finalizar en programaci\u00f3n?","isPartOf":{"@id":"https:\/\/www.techopedia.com\/es\/#website"},"datePublished":"2024-07-12T04:53:49+00:00","dateModified":"2024-07-12T08:03:44+00:00","description":"En t\u00e9rminos de programaci\u00f3n el evento finalizar tiene una funci\u00f3n importante en el \u00e1rea de limpieza de un dispositivo, te la explicamos.","breadcrumb":{"@id":"https:\/\/www.techopedia.com\/es\/definicion\/finalizar#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.techopedia.com\/es\/definicion\/finalizar"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.techopedia.com\/es\/definicion\/finalizar#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Inicio","item":"https:\/\/www.techopedia.com\/es\/"},{"@type":"ListItem","position":2,"name":"Term","item":"https:\/\/www.techopedia.com\/es\/definicion"},{"@type":"ListItem","position":3,"name":"Finalizar"}]},{"@type":"WebSite","@id":"https:\/\/www.techopedia.com\/es\/#website","url":"https:\/\/www.techopedia.com\/es\/","name":"Techopedia","description":"","publisher":{"@id":"https:\/\/www.techopedia.com\/es\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.techopedia.com\/es\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/www.techopedia.com\/es\/#organization","name":"Techopedia en Espa\u00f1ol","url":"https:\/\/www.techopedia.com\/es\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.techopedia.com\/es\/#\/schema\/logo\/image\/","url":"https:\/\/www.techopedia.com\/es\/wp-content\/uploads\/sites\/4\/2025\/02\/techopedia-light-logo.svg","contentUrl":"https:\/\/www.techopedia.com\/es\/wp-content\/uploads\/sites\/4\/2025\/02\/techopedia-light-logo.svg","caption":"Techopedia en Espa\u00f1ol"},"image":{"@id":"https:\/\/www.techopedia.com\/es\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.techopedia.com\/es\/#\/schema\/person\/f5dd538e31ee352d105b8af36c4268a5","name":"Margaret Rouse","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.techopedia.com\/es\/#\/schema\/person\/image\/","url":"https:\/\/www.techopedia.com\/wp-content\/uploads\/2023\/02\/margaret-rouse-headshot.jpeg","contentUrl":"https:\/\/www.techopedia.com\/wp-content\/uploads\/2023\/02\/margaret-rouse-headshot.jpeg","caption":"Margaret Rouse"},"description":"Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret's idea of a fun day is helping IT and business professionals learn to speak each other\u2019s highly specialized languages.","sameAs":["https:\/\/www.linkedin.com\/in\/margaretrouse\/","https:\/\/x.com\/https:\/\/twitter.com\/@techdefinitions"],"knowsAbout":["Technology Expert"],"url":"https:\/\/www.techopedia.com\/es\/autor\/margaret-rouse"}]}},"_links":{"self":[{"href":"https:\/\/www.techopedia.com\/es\/wp-json\/wp\/v2\/definition\/38112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techopedia.com\/es\/wp-json\/wp\/v2\/definition"}],"about":[{"href":"https:\/\/www.techopedia.com\/es\/wp-json\/wp\/v2\/types\/definition"}],"author":[{"embeddable":true,"href":"https:\/\/www.techopedia.com\/es\/wp-json\/wp\/v2\/users\/7813"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techopedia.com\/es\/wp-json\/wp\/v2\/comments?post=38112"}],"version-history":[{"count":0,"href":"https:\/\/www.techopedia.com\/es\/wp-json\/wp\/v2\/definition\/38112\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.techopedia.com\/es\/wp-json\/wp\/v2\/media?parent=38112"}],"wp:term":[{"taxonomy":"definitioncat","embeddable":true,"href":"https:\/\/www.techopedia.com\/es\/wp-json\/wp\/v2\/definitioncat?post=38112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}