Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re: Garbage collection problem #2365

Closed
vicuna opened this issue Jan 27, 2000 · 2 comments
Closed

Re: Garbage collection problem #2365

vicuna opened this issue Jan 27, 2000 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 27, 2000

Original bug ID: 34
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hi,

Thank you for your message to the Caml mailing list.

However your message seems to be a bug report; hence I send it to the
relevant mailing list

caml-bugs@inria.fr

Thank again for your interest in Caml.

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/

The following piece of code will:

  • Create a table in a database.

  • Load the table with a list of rows.

  • Select and print the contents of the table gIter times.

  • Delete the contents of the table.

  • Drop the table from the database.

    let main conn =
    ED.create conn; (* Create the table )
    List.iter (ED.put conn) data; (
    Load the table )
    for i = 1 to !gIter do (
    Select and print )
    EStrm.iter ED.printer conn ("select * from " ^ ED.tableName)
    done;
    ED.delete conn; (
    Delete the contents )
    ED.drop conn (
    Drop the table *)

The problem I'm having is that the code will fail with a segmentation
violation for sufficiently large values of gIter (> 10000). This occurs
under a variety of databases including Postgres, Mysql(IODBC), Sybase ASE
(Linux), and ODBC under Windows NT 4.0.

At first, I suspected that the problem must be in my foreign function
libraries. Further tests showed that there a appeared to be a memory
leak. Then I tried moving the loop outside:

let main conn =
for i = 1 to !gIter do
ED.create conn;
List.iter (ED.put conn) data;
EStrm.iter ED.printer conn ("select * from " ^ ED.tableName)
ED.delete conn;
ED.drop conn
done

This ran without any problems so I began to suspect the databases.

Then I tried adding a call to Gc.minor():

let main conn =
ED.create conn;
List.iter (ED.put conn) data;
for i = 1 to !gIter do
Gc.minor();
EStrm.iter ED.printer conn ("select * from " ^ ED.tableName)
done;
ED.delete conn;
ED.drop conn

This seemed to clear up all problems with the first version. The
memory consumed by the application remained constant for very
large values of gIter and no crashes occurred.

Are their situations where it's necessary to call Gc functions
or is this a bug? What are the costs associated with calling
Gc functions?

I'm running OCaml 2.04 under RedHat Linux 6.0 and Windows NT 4.0 SP5.

@vicuna
Copy link
Author

vicuna commented Feb 3, 2000

Comment author: administrator

Bug in user code (Caml ptr stored in finalized block)

@vicuna vicuna closed this as completed Feb 3, 2000
@vicuna
Copy link
Author

vicuna commented Jan 7, 2005

Comment author: administrator

Merci pour l'aide que vous m'avez apporté .
Effectivement cela fonctionne et j'ai remarqué une chose aussi c'est qu'il vaut mieux faire :

dessiner (le dessin);;
while true do () done ;;
comme vous dites

plutôt que
while true do (dessiner (le dessin)) done ;;
parce que ainsi il redessine à chaque fois et ça se voit .

Merci encore et bonne année.

Sincèrement .Frédéric .

Damien Doligez caml-bugs@pauillac.inria.fr wrote:

Full_Name:
Version: ocaml 3.08.2

Soit le programme suivant qui ouvre une fenetre qui s'appelle fenetre.ml
open_graph"";;

J'exécute le fichier .exe
./ocamlrun fenetre.exe(une fenetre souvre et disparaît aussitôt)

La fenetre disparait quand le programme ferme la fenetre explicitement
avec close_graph, ou bien quand le programme se termine.

Que puis-je faire pour que la fenetre reste ?

Ecrire un programme qui ne termine pas immediatement:

open_graph "";;
while true do () done;;

-- Damien


Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails !
Créez votre Yahoo! Mail

Merci pour l'aide que vous m'avez apporté .
Effectivement cela fonctionne et j'ai remarqué une chose aussi c'est qu'il vaut mieux faire :
 
dessiner (le dessin);;
while true do () done ;;
comme vous dites
 
plutôt que
while true do (dessiner (le dessin)) done ;;
parce que ainsi il redessine à chaque fois et ça se voit .
 
Merci encore et bonne année.
 
Sincèrement .Frédéric .  

Damien Doligez <caml-bugs@pauillac.inria.fr> wrote:
> Full_Name:
> Version: ocaml 3.08.2

> Soit le programme suivant qui ouvre une fenetre qui s'appelle fenetre.ml
> open_graph"";;

> J'exécute le fichier .exe
> ./ocamlrun fenetre.exe(une fenetre souvre et disparaît aussitôt)

La fenetre disparait quand le programme ferme la fenetre explicitement
avec close_graph, ou bien quand le programme se termine.

> Que puis-je faire pour que la fenetre reste ?

Ecrire un programme qui ne termine pas immediatement:

open_graph "";;
while true do () done;;

-- Damien


Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails !
Créez votre Yahoo! Mail ---------------- ----------------

@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant