Foros del Web » Programando para Internet » ASP Clásico »

como limpiar o Resetear Grandes Arreglos ?

Estas en el tema de como limpiar o Resetear Grandes Arreglos ? en el foro de ASP Clásico en Foros del Web. Uso algo como esto para almacenar el objeto Recordset y cerrar la conexion con la BD (uso ASP 3.0 con Win 2k): arrDatos = objRegs.getRows() ...
  #1 (permalink)  
Antiguo 27/04/2006, 11:42
Avatar de xlugo2002  
Fecha de Ingreso: noviembre-2002
Ubicación: Puebla, México
Mensajes: 474
Antigüedad: 21 años, 7 meses
Puntos: 0
como limpiar o Resetear Grandes Arreglos ?

Uso algo como esto para almacenar el objeto Recordset y cerrar la conexion con la BD (uso ASP 3.0 con Win 2k):

arrDatos = objRegs.getRows()

Ahora bien, libero la conexion con la base de datos para evitar consumir recursos; PERO cometí un error al no limpiar el arreglo arrDatos, éstos arreglos se kedan llenos y creo ke me estan robando memoria y despues el servidor IIS ya no puede servir paginas.

¿Como debo limpiar ese arreglo?

Como poner a 0,0 los limites del arreglo o limpiarlo o resetearlo ?????????


Esa ultima pregunta esta mal, no kiero limpiar el arreglo , lo ke kiero es liberar la memoria ocupada por el arreglo o destruir el arreglo.

Última edición por xlugo2002; 27/04/2006 a las 12:58
  #2 (permalink)  
Antiguo 27/04/2006, 11:48
Avatar de u_goldman
Moderador
 
Fecha de Ingreso: enero-2002
Mensajes: 8.031
Antigüedad: 22 años, 5 meses
Puntos: 98
Lo recomendable aqui seria borrar ese arreglo

erase arreglo


Saludos
__________________
"El hombre que ha empezado a vivir seriamente por dentro, empieza a vivir más sencillamente por fuera."
-- Ernest Hemingway
  #3 (permalink)  
Antiguo 27/04/2006, 13:03
Avatar de xlugo2002  
Fecha de Ingreso: noviembre-2002
Ubicación: Puebla, México
Mensajes: 474
Antigüedad: 21 años, 7 meses
Puntos: 0
funciona esto ?

ReDim arrDatos(0)
Erase arrDatos



Creo ke kon eso reinicio el array a 0 y elimino los elementos del arreglo, con esto liberaria la memoria no ?????
  #4 (permalink)  
Antiguo 27/04/2006, 13:06
Avatar de u_goldman
Moderador
 
Fecha de Ingreso: enero-2002
Mensajes: 8.031
Antigüedad: 22 años, 5 meses
Puntos: 98
El método erase borrará el arreglo, no creo que sea necesario hacer una redimensión previo a utilizarlo.

Saludos
__________________
"El hombre que ha empezado a vivir seriamente por dentro, empieza a vivir más sencillamente por fuera."
-- Ernest Hemingway
  #5 (permalink)  
Antiguo 27/04/2006, 15:18
Avatar de xlugo2002  
Fecha de Ingreso: noviembre-2002
Ubicación: Puebla, México
Mensajes: 474
Antigüedad: 21 años, 7 meses
Puntos: 0
Nota

STATEMENT: Erase

--------------------------------------------------------------------------------
Implemented in version 1.0

Erase

The Erase statement is used to empty arrays.

If the array is fixed (static), this statement removes the values for all of the elements. If the fixed array is a string array, all of the string elements are reinitialized to "". If the fixed array is a numeric array, all of the numeric elements are reinitialized to 0. So the memory remains allocated for the elements. The array continues to exist with the same size (in the example 3), but the elements are essentially zeroed out.

Fixed array:

Code:
<% Dim myarray(3) %>
<% myarray(0) = 111 %>
<% myarray(1) = 222 %>
<% myarray(2) = 333 %>
<% Erase myarray %>

If the array is dynamic, the erase statement frees the memory allocated to the dynamic array and the array is destroyed. If you try to access an element in the erased array, you will get an error message (array out of bounds) since the elements do not exist in memory any more. However, you can reinitialize the array by using ReDim. This ability to free memory is very useful.

Dynamic array:

Code:
<% Dim anarray() %>
<% ReDim anarray(3) %>
<% anarray(0) = "First string." %>
<% anarray(1) = "Second string." %>
<% anarray(2) = "Third string." %>
<% Erase anarray %>
  #6 (permalink)  
Antiguo 27/04/2006, 15:23
Avatar de u_goldman
Moderador
 
Fecha de Ingreso: enero-2002
Mensajes: 8.031
Antigüedad: 22 años, 5 meses
Puntos: 98
No se cual es la intención de tu post, pero si estás creando el array mediante getRows, esto aplica a tí:

If the array is dynamic, the erase statement frees the memory allocated to the dynamic array and the array is destroyed.

Por eso es que te dije que no era necesario inicializar sus índices...y si aún lo dudas, puedes probar, destrúyelo y trata de acceder a cualquier índice.

[EDIT]En cuánto a los estáticos la verdad no sabía eso, siempre lo trabajé para borrar los dinámicos.[/EDIT]

Saludos
__________________
"El hombre que ha empezado a vivir seriamente por dentro, empieza a vivir más sencillamente por fuera."
-- Ernest Hemingway

Última edición por u_goldman; 27/04/2006 a las 15:28
  #7 (permalink)  
Antiguo 27/04/2006, 17:06
Avatar de xlugo2002  
Fecha de Ingreso: noviembre-2002
Ubicación: Puebla, México
Mensajes: 474
Antigüedad: 21 años, 7 meses
Puntos: 0
ok,

Perdón pensé ke mi arreglo era estatico, pero no es asi.

Muchas gracias !!!!!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:35.