[freetds] Memory Overflow on apache using freetds and php

Aliet Santiesteban Sifontes alietss at yahoo.com
Thu May 29 13:47:22 EDT 2003

Hi all:
The tables have 42539 records, and ASSNS_Almacen has
61 records, I'm doing the query to return all of
them. FreeTDS and php configured with defaults values
in freetds.conf with TDS
version 7.0 against a Microsoft SQL Server 2000, php
with defaults too.
As overview, I'm doing a query to ASSNS_Almacen table,
after that I'm moving for each element
of the recordset, and doing a query for each element
to the other three tables, I write the script at the 
end of the tables. 

Here the design of the tables:

Id_Producto          char           20
Id_Almacen           char           5
Existencia_Actual    decimal        9
Pto_Reorder          decimal        9

Id_Producto          char           20
Precio_CostoMB       char           9
Precio_CostoMC       char           9

Id_Producto          char           20
Desc_Producto        varchar        255
Fecha_Entrada        smalldatetime  4
UM_Venta             char           5
Id_Categoria         char           10
Id_SubCategoria      char           10
Nota                 varchar        255  

Id_Almacen           char           5
Desc_Almacen         varchar        50
Direccion            varchar        255
Id_Ccosto            char           10

Here the function

function render_existencia_productos_page(){
   // Well let's get the post vars
   list($id_almacen,$id_cat, $id_subcat) =

	  // Let's cokment this, since is a really pain when
	  // with a lot of reports 
      /*if (!swSecConfirmAuthKey()) {
        echo "Error en la llave de autenticidad";
	   <div align="center"><h1>Listado de las Existencias
de Productos</h1></div>
	  list($dbconn) = swDBGetConn();
      $swtable = swDBGetTables();
	  // Tabla de los Almacenes
	  $almacentable = $swtable['ASSNS_Almacen'];
      $almacentablecolumn =
	  // Selecciono todos los Almacenes
     $query = "SELECT $almacentablecolumn[idalm],
               FROM $almacentable
               ORDER BY
	  // Ahora seleccionemos los conceptos dependiendo
del rango de fecha
	  // seleccionado o el año completo
	  $result_almacenes = $dbconn->Execute($query);
	  if($dbconn->ErrorNo() != 0) {
         die("Error con la consulta de los
	  echo "<table width=\"100%\" border=\"0\"
cellspacing=\"0\" cellpadding=\"0\">
        <td width=\"50%\"><b>Rango de Fecha: ".
$texto_fecha." <b></td>
	  // Ciclo para listar todos los Almacenes
	  while(list($cod_alm, $desc_alm) =
$result_almacenes->fields) {
	  	echo "<table width=\"100%\" border=\"0\"
cellspacing=\"0\" cellpadding=\"0\">
                <td width=\"50%\"><b>Id Almacén:
".$cod_alm." <b></td>
                <td width=\"50%\"
align=\"right\"><b>Descripción: ".$desc_alm." <b></td>
		 // Selección de los Productos
	    $productostable = $swtable['ASSNS_Productos'];
        $productostablecolumn =
		$existenciatable = $swtable['ASSNS_Existencia'];
        $existenciatablecolumn =
		$existencialotestable =
        $existencialotestablecolumn =
		$query = "SELECT $productostablecolumn[idprod],
                         FROM $productostable,
$existenciatable, $existencialotestable
						 AND $existenciatablecolumn[idprod] =
						 AND $existenciatablecolumn[idalm] =
		 //echo $query;
		 $result_productos_almacen =
	     if($dbconn->ErrorNo() != 0) {
        	die("Error con la consulta de los Productos
en el Almacén");

	  <table style="padding-bottom: 15px;" width="100%"
cellspacing="1" cellpadding="4" class="list"
       <!-- Begin Header Row -->
         <th align="center" width="8%">Código</th>
         <th align="center"
         <th align="center" width="30%">UM</th>
		 <th align="center" width="10%">Precio USD</th>
		 <th align="center" width="10%">Precio MN</th>
		 <th align="center" width="15%">Existencia
      <!-- End Header Row -->
	  while(list($idprod, $descripcion, $um, $ex_act,
$precio_mb, $precio_mc) =
$result_productos_almacen->fields) {
		// Formateamos las salidas	
		$precio_mb = sprintf ("%01.2f",$precio_mb);
		$precio_mc = sprintf ("%01.2f",$precio_mc);
	  <tr class="table-tree-even">
       <td align="left" width="8%">
	   <?php echo $idprod;?>
       <td align="left" width="18%">
       <?php echo $descripcion;?>
       <td align="left" width="30%">
	   <?php echo $um;?>
	   <td align="right" width="29%">
	   <?php echo $ex_act;?>
	   <td align="right" width="15%">
	   <?php echo $precio_mb;?>
	   <td align="right" width="15%">
	   <?php echo $precio_mc;?>
	  // Continúa el while
	  } // Fin del ciclo de las operaciones de un
	  <table style="padding-bottom: 15px;" width="100%"
cellpadding="4" class="list" align="center">
       <!-- Begin Header Row -->
		 <th align="right" width="25%"><b>Cantidad de
		 <th align="right" width="5%"><b><?php ?></b></th>
		 <th align="right" width="55%"><b>Total por
		 <th align="right" width="15%"><b><?php ?></b></th>
	  <hr size="1"/>

--- Frediano Ziglio <freddyz77 at tin.it> wrote:
> Il gio, 2003-05-29 alle 05:55, Aliet Santiesteban
> Sifontes ha scritto:
> > Hi people:
> > I'm testing freetds-0.62, php-4.3.2, httpd-2.0.45
> on
> > RedHat Linux 9.0, I'm doing a query wich have a
> lot of
> > data to return, this is causing apache to stop
> with
> > this error....
> > Allowed memory size of 8388608 bytes exhausted
> (tried
> > to allocate 10240 bytes)
> > I think that there some process wich is consuming
> a
> > lot of memory when there's a lot of data.
> >                     Do you have any ideas
> >                                  Regards Aliet
> >  
> Thanks for testing.
> What do you mean by "lot of data to return" ??
> The limit is 8mb so returning a big text/image can
> consume all memory
> available...
> freddy77
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds

Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).

More information about the FreeTDS mailing list