You are not logged in.

Hardo

Beginner

  • "Hardo" started this thread

Posts: 5

Date of registration: Jan 19th 2010

  • Send private message

1

Saturday, January 23rd 2010, 11:40am

Out of stack space (Run-tine 28)

Nachdem ich über die Zeitschrift "database pro" auf Jabaco aufmerksam geworden bin, mache ich nun meine ersten Schritte mit diesem interessanten Entwicklungswerkzeug. Endlich habe ich Gelegenheit, mit geringem Aufwand mal einiges zu probieren. Mein Versuchskanditat ist das freie objektorientierte DBMS db4objects. Von hier habe ich die aktuelle Version für Java herunter geladen. Beim Nachstellen der ersten Schritte aus dem mitgelieferten Tutorial gab es die ersten Erfolgserlebnisse, aber bald leider auch das für mich unüberwindliches Hindernis "Out of stack space", mit dem sich die Jabaco-IDE gleich nach dem Projektstart verabschiedete.

Der folgende Code zeigt meine kleine Konsolenanwendung. Im Classpath ist der Standort des verwendeten db4o-Pakets (db4o-7.12.126.14142-all-java1.2.jar) hinterlegt.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
' globals - globale Variable

Dim dbfilename As String = "c:/Testdaten/formula1.db4o" ' DB-Datei
Dim DB     As com#db4o#ObjectContainer
Dim oSet   As com#db4o#ObjectSet
Dim osResult   As com#db4o#ObjectSet

Dim pilot1 As New Pilot()
Dim pilot2 As New Pilot()
Dim proto  As New Pilot()
Dim p  As New Pilot()


Public Sub main(ByJava args() As String)
   Dim myArgs() As String
   myArgs = args
   ' [Your Source]
   
   On Error Goto ErrOut
   ' open database
   Println()
   Println("Open DB")  
   DB = db4o.openFile(dbfilename)
   
   ' create pilots
   Println()
   Println("Create pilots")
   CreatePilots()

   ' store pilots
   Println()   
   Println("Store pilots")
   StorePilots()
   
   ' read all pilots
   ' query by example: 
   '  Search all objects of a class which the same field values as the sample.
   '  An empty prototype has in all fields Null or 0
   proto.Name = Null
   proto.Points = 0   
   Println()
   Println("Read all pilots")
   osResult = DB.get(proto)   
   ' a shorter way
   ' osResult = DB.get(Pilot.class)
   Println()
   ListResult(osResult)
   
   ' find pilot by name
   Dim name As String = "Michael Schumacher"
   Println()
   Println("Find pilot by name: " & name)
   FindPilotsByName(name)
   
   ' find pilot by points
   Dim points As Integer = 90
   Println()
   Println("Find pilot by points: " & points)
   FindPilotsByPoints(points)

   ' update pilot
   Println()
   Println("Update pilot")
   UpdatePilotsByName("Michael Schumacher", 5)  
   osResult = DB.get(Pilot.class)
   Println()
   ListResult(osResult)  
   
   ' delete pilot by name
   Println()
   Println("Delete pilot: " & name)
   DeletePilotsByName(name)
   osResult = DB.get(Pilot.class)
   Println()
   ListResult(osResult)  

   ' delete pilot by points
   Println()
   Println("Delete pilot: " & points)
   DeletePilotsByPoints(points)
   osResult = DB.get(Pilot.class)
   Println()
   ListResult(osResult)  

   ' close db - DB schließen
   DB.close()
   Println()
   Println("Close DB")

   Println()
   Println("Enter ends the programm")
   Readln()  
   Exit Sub

ErrOut:
   MsgBox Err.toString()
End Sub

Public Sub CreatePilots()
   pilot1.Name = "Michael Schumacher"
   pilot1.Points = 100
   Println(pilot1.toString())
  
   pilot2.Name = "Rubens Barricello"
   pilot2.Points = 90
   Println(pilot2.toString())
End Sub

Sub StorePilots()
   DB.set(pilot1)
   Println(pilot1.toString())
   DB.set(pilot2)
   Println(pilot2.toString())
End Sub

Sub FindPilotsByName(name As String)
   proto.Name = name
   proto.Points = 0   
   osResult = DB.get(proto)
   Println()
   ListResult(osResult)
End Sub

Sub FindPilotsByPoints(points As Integer)
   proto.Name = Null
   proto.Points = points   
   osResult = DB.get(proto)
   Println()
   ListResult(osResult)   
End Sub

Sub UpdatePilotsByName(name As String, points As Integer)
   proto.Name = name
   proto.Points = 0   
   osResult = DB.get(proto)   
   Do While osResult.hasNext()
  p = Cast(osResult.next(), Pilot)
  p.AddPoints(points)  
  DB.set(p)
  Println(points & " points added to " + p.Name)
   Loop
End Sub

Sub DeletePilotsByName(name As String)
   proto.Name = name
   proto.Points = 0
   osResult = DB.get(proto)
   Do While osResult.hasNext()
  p = Cast(osResult.next(), Pilot)
  DB.delete(p)
  Println(p.Name & " deleted")
   Loop
End Sub

Sub DeletePilotsByPoints(points As Integer)
   proto.Name = Null
   proto.Points = points
   osResult = DB.get(proto)
   Do While osResult.hasNext()
  p = Cast(osResult.next(), Pilot)
  DB.delete(p)
  Println(p.toString() & " deleted")
   Loop
End Sub

Sub ListResult(oSet As com#db4o#ObjectSet)
   Dim p As Pilot
   Println(oSet.size() & " Objekte in der DB.")
   Do While oSet.hasNext()
  p = Cast(oSet.next(), Pilot)
  Println(p.toString())
   Loop
End Sub

Sub Println(Optional text As String)
   system.out.println(text)
End Sub

Function Readln()
   Readln = system.in.read()
End Function


Die Klasse Pilot hat folgendes Aussehen:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Private m_name As String
Private m_points As Integer

Public Property Get Name() As String
   Name = m_name
End Property

Public Property Let Name(value As String)
   m_name = value
End Property

Public Property Get Points() As String
   Points = m_points
End Property

Public Property Let Points(value As Integer)
   m_points = value
End Property

Public Sub AddPoints(value As Integer)
   m_points = m_points + value
End Sub

Public Function toString()
   toString = m_name & " / " & m_points
End Function


Ein paar mal ist das kleine Projekt aber auch fehlerfrei durchgelaufen, ehe sich dann das unerbittliche "Out of..." zeigte.
Gibt es hier einen Ausweg für mich? Danke für eventuelle Hinweise.
Grüße von Hardo.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Saturday, January 23rd 2010, 12:57pm

Ich kann dem Beispiel nicht auf Anhieb ansehen, warum es soviel Stack Space braucht.
Es kann sich um einen Fehler oder um einen beabsichtigten Ablauf handeln.

Compiliert man das Jabaco-Projekt in ein Jar-File, so kann man dieses mit Java-Parametern aufrufen,
die Stack und Heap vorgeben:

Source code

1
java -Xss4M -Xms32M -Xmx128M xyKlasse


Überläufe des Stack gibt's normalerweise entweder bei endloser Rekursion oder bei zu großen lokalen Variablen.
Kannst Du mit dem Debugger die Stelle eingrenzen, wo der Abbruch passiert?

Dein Beispiel ist zu umfangreich und auf nicht verfügbare Randbedingungen angewiesen, um es mal so eben nachzustellen.

Gruß!

A1880

  • "StefanSchnell" is male

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

3

Wednesday, January 27th 2010, 10:54am

Hallo hardo,
willkommenn bei Jabaco.

db4o ist eine sehr interessante Datenbank. Ich habe mal folgenden Test vorgenommen, der zwar nicht so umfangreich ist wie Deiner, aber einwandfrei mehrfach funktionierte:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'-Begin Class Pilot-----------------------------------------------------

  Private mName As String
  Private mPoints As Integer
  
  Public Sub Pilot(Name As String, Points As Integer)
    mName = Name
    mPoints = Points
  End Sub  
  
  Property Get Points()
    Set Points = mPoints
  End Property  

  Public Sub addPoints(Points As Integer)
    mPoints = mPoints + Points
  End Sub  

  Property Get Name()
    Set Name = mName
  End Property  

  Public Function toString() As String
    toString = mName & "/" & CStr(mPoints)
  End Function  

'-End Class Pilot-------------------------------------------------------


und das ausführende Modul dazu

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'-Begin-----------------------------------------------------------------

  Private Sub listResult(Result As ObjectSet)
    java#lang#System.out.println(Result.size())
    Do While Result.hasNext()
      java#lang#System.out.println(Result.next())
    Loop
  End Sub

'-----------------------------------------------------------------------

  Public Sub Command1_Click()
  
    Dim db As ObjectContainer
    db = db4o.openFile("c:\dummy\test.db4o")
  
    Dim Pilot1 As New Pilot("Michael Schuhmacher", 100)
    db.store(Pilot1)
    java#lang#System.out.println("Stored " & Pilot1)
  
    Dim Pilot2 As New Pilot("Rubens Barrichello", 99)
    db.store(Pilot2)
    java#lang#System.out.println("Stored " & Pilot2)
  
    Dim result As ObjectSet = db.queryByExample(Pilot.class)
    listResult(result)
  
    db.close()
   
  End Sub

'-End-------------------------------------------------------------------


Ich werde das Tutorial von db4o mal weiter durcharbeiten und sehen ob ich auf den gleichen Fehler stoße.

Was ich allerdings nicht so ganz verstehe: IM Artikel der database pro und im Tutorial von db4o werden vielfach die Methoden der Klasse db4o verwendet, die aber in der Dokumentation als depreciated gekennzeichnet sind - "Ist wohl nicht mehr die Höhe der Zeit".

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

Hardo

Beginner

  • "Hardo" started this thread

Posts: 5

Date of registration: Jan 19th 2010

  • Send private message

4

Friday, January 29th 2010, 7:48pm

Hallo Stefan,
schön, dass Dich das Thema interessiert und dass Du bei den ersten Schritte erfolgreich warst. Dein Beispiel bringt bei mir leider auch sofort nach F5 den Runtime-Fehler. Welches db4o-Paket hast Du verwendet und wie hast Du es refenziert?
Gruß Hardo.

  • "StefanSchnell" is male

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

5

Saturday, January 30th 2010, 7:18am

Hallo Hardo,
ich verwende die Version 7.12.126.14142 von db4o und referenziere auf das Paket db4o-7.12.126.14142-core-java5.jar. Hoffe dass Dir das schon hilft.

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

This post has been edited 1 times, last edit by "StefanSchnell" (Jan 30th 2010, 7:25am)


Hardo

Beginner

  • "Hardo" started this thread

Posts: 5

Date of registration: Jan 19th 2010

  • Send private message

6

Sunday, January 31st 2010, 5:53pm

Hallo Stefan,
ich hatte bisher das Paket db4o-7.12.126.14142-all-java5.jar referenziert, so wie es im wirklich guten Tutorial von db4o irgendwo empfohlen wird. Nun habe ich auch das kleinere db4o-7.12.126.14142-core-java5.jar verwendet, bin damit aber leider auch ohne Erfolg geblieben. Vielleicht kommt Jabaco nicht mit der Umgebung zurecht, in der es bei mir laufen muss: Windows 7 Pro in einer vituellen Maschine (MS Virtual PC), aber mit genügend RAM (1,5 GB).

Um meine Absichten bezüglich db4o weiter verfolgen zu können, habe ich mich nun auf den Weg gemacht, den ich mit Jabaco ev. vermeiden zu können hoffte: ich probiere direkt in einer Java-IDE (Eclipse). Da laufen meine bisherigen db4o-Test in der oben genannten Umgebung klaglos. Ich habe hier als Java-Neuling allerdings einen größeren Lernaufwand und ziemlichen Respekt vor der Arbeit an den GUI's, die mir für meine Sachen vorschweben.

Vielen Dank für Deine Antworten.
Gruß Hardo.

  • "StefanSchnell" is male

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

7

Tuesday, February 2nd 2010, 12:24pm

Hallo Hardo,

im Java-Magazin 3.2010 steht auf der Seite 8 dass das Java 6 Update 18 verfügbar sei und dass nun auch Windows 7 unterstützt wird. Vielleicht liegt Dein Problem einfach nur an der bisherigen (mangelnden) Unterstützung Deines Betriebssystem. Die Release-Note findest Du hier.

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

Wolfgang

Beginner

Posts: 1

Date of registration: Apr 12th 2010

  • Send private message

8

Monday, April 12th 2010, 6:21pm

Out of stack space (Run-tine 28)

Hallo zusammen,

ich kämpfe ebenfalls mit dem stack Problem. Bei mir schlägt der Fehler immer zu, wenn ich das Projekt abgespeichert hatte! Die Umgebung ist Windows XP, db4o-7.12.132.14217-all-java5.jar und Java 6 Update 19.

Wie sieht es denn inzwischen bei Dir Hardo aus??

Gruß

Wolfgang

Rate this thread
WoltLab Burning Board