Home All Groups Group Topic Archive Search About
Author
28 Jun 2005 7:15 AM
Steve
Hi all,

I had a strange crash this morning with an app I've been working on.
I just clicked the main menu bar and got an OutOfMemory exception,
with a message of something like "unable to get info to create bitmap".
(not the correct wording but I was in a hurry and didn't think to
copy/paste it somewhere).

The app is just a basic winforms app and it was not "doing" anything
at the time.  ie no threads running, not working on anything... just sitting
there. The menu is not even large. There are only 2 menu headings,
one with 2 items, the other with 5.

This app has been used daily for 8-9 months with no probs. I have never
seen this crash before and I can't reproduce it.

Anyone encountered anything like this ??   Are there perhaps any known
bugs in  .NET's menu handling ???

thanks in advance
Steve

Author
28 Jun 2005 8:04 AM
Cor Ligthert
Steve,

No timer in it where in you create bitmaps everytime new which have a global
reference and therefore are very slowly filling the memory?

I want to say with this, that the behaviour you tell is not impossible.

In past I wrote often that I like recursive programming.

Standard I got than the answer from Herfried.
"As long as you have enough memory"

Cor
Author
28 Jun 2005 8:36 AM
Steve
"Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message
news:Ot2Hcg7eFHA.3028@TK2MSFTNGP09.phx.gbl...
> Steve,
>
> No timer in it where in you create bitmaps everytime new which have a
> global reference and therefore are very slowly filling the memory?
>
> I want to say with this, that the behaviour you tell is not impossible.

Hi Cor,

No I have no timers and I do not use bitmaps anywhere. My app is an MSDE
front end
using mostly listviews for display of data. The total amount of records in
my biggest
table is only around 15000, and if I display these in a listview my app uses
around 50mb
of RAM. My system has 1GB, and task manager says I have 600MB free even with
that
listview fillled. So it is not RAM related.

I wonder if the OutOfMemory exception perhaps relates to video memory and
the issue
is video-driver related ??

thanks
Steve
Author
28 Jun 2005 9:45 AM
Cor Ligthert
Steve,

Normally it is a loop.

For the rest do I have no expirience with it.

However don't trust the taskmanager.

See for that this message from Willy in the dotNet General newsgroup.

It is very well done.
http://groups-beta.google.com/group/microsoft.public.dotnet.general/msg/392a8e932c39983d?hl=en

I hope this helps,

Cor
Author
28 Jun 2005 11:20 AM
Steve
"Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message
news:%232YeOZ8eFHA.2420@TK2MSFTNGP12.phx.gbl...
> Steve,
> Normally it is a loop.
> For the rest do I have no expirience with it.
> However don't trust the taskmanager.
> See for that this message from Willy in the dotNet General newsgroup.
> It is very well done.
> http://groups-beta.google.com/group/microsoft.public.dotnet.general/msg/392a8e932c39983d?hl=en

Thanks Cor I will have a read.

No matter what I do I can't seem to replicate this crash. I just tried
running my app alongside a whole stack of other programs in
order to use up lots of ram. I filled all the listviews in my app
with the max amount of records available, meaning a total
of around 20000 listview items across my app. I then re-filled
all the listviews 10 times using the same queries. The menus
still work fine.

This morning when I had the menu crash I had only used my app
for a few seconds and run a couple of queries (the same queries
as I tried above).

thanks
Steve
Author
28 Jun 2005 11:37 AM
Cor Ligthert
Steve,

I am now aware that you say listview and create them.

What for me becomes than direct a question, "Do you create maybe used
intermidiate arrays and than how?

By instance setting something globaly means that always forever the last
created stays in memory.

Can you show that procedure that fills that listview (the real one not a
snippet, I have some wrong expiriences the last three day because people
were sending that and than told: It was not the real one I showed, that was
an example. I forgot something in the real one).

Cor
Author
28 Jun 2005 12:00 PM
Steve
"Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message
news:ONBBlX9eFHA.3880@tk2msftngp13.phx.gbl...
> Steve,
>
> I am now aware that you say listview and create them.
>
> What for me becomes than direct a question, "Do you create maybe used
> intermidiate arrays and than how?

No I just fill the listview directly using a datareader

> By instance setting something globaly means that always forever the last
> created stays in memory.
>
> Can you show that procedure that fills that listview (the real one not a
> snippet, I have some wrong expiriences the last three day because people
> were sending that and than told: It was not the real one I showed, that
> was an example. I forgot something in the real one).

Here's an example of how I fill a listview. All the listviews in my
app are filled using variations of this code.

thanks
Steve


'suspend listview drawing whilst populating. clear listview
  lstItems.BeginUpdate()
   lstItems.Items.Clear()

'attempt to open database
If OpenDatabase(ShowError) Then

'create command string to retrieve all non-deleted customers
myCommand.CommandText = "" & _
"SELECT customerID, name, distributor, phone " & _
"FROM Customers " & _
"WHERE (deleted = 0) " & _
"ORDER BY name"

Try

'start datareader
StartMyDataReader()

Do While myDataReader.Read

'create listview item object
Dim objCustomer As New ListViewItem

'assemble item
objCustomer.Text = CStr(myDataReader("name"))
objCustomer.SubItems.Add(CStr(myDataReader("phone")))
objCustomer.SubItems.Add(CStr(myDataReader("customerID")))

'add to listview
lstItems.Items.Add(objCustomer)

Loop

Catch ex As Exception

'failed. display error
MsgBox("Cannot load customer listing !", MsgBoxStyle.Critical, "ERROR!")

End Try

myDataReader.Close()
CloseDatabase(ShowError)

End If

  'resume listview drawing
  lstItems.EndUpdate()
Author
28 Jun 2005 12:35 PM
Cor Ligthert
Steve,

In my opinion is there nothing that can be wrong in that code.
At least I would not know how you could do this shorter.

I would try this one, however I do not know why.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsListViewClassClearTopic.asp

I am afraid, that it will be a long way to find that error.

And probably not helpable from this side.
Just the hard terrible way.

:-)

Cor
Author
28 Jun 2005 1:15 PM
Steve
Show quote Hide quote
"Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message
news:OvtDu39eFHA.2244@TK2MSFTNGP15.phx.gbl...
> Steve,
>
> In my opinion is there nothing that can be wrong in that code.
> At least I would not know how you could do this shorter.
>
> I would try this one, however I do not know why.
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsListViewClassClearTopic.asp
>
> I am afraid, that it will be a long way to find that error.
>
> And probably not helpable from this side.
> Just the hard terrible way.

Thanks for your help Cor.

I am wondering if this is a bug relating to how
..NET allocates graphics memory for it's controls.

Originally in my app I had implemented nice auto-resizing
columns in my listviews. This meant that as the user
resized the window the listview columns would
always stretch to fill the width of the window. I did
this by handling the .sizechanged event of the window
and then setting each column width to a percentage
which I had preset at startup. This looked very nice and
seemed to work fine. However I noticed that when a
listview had a large no. of items I would occasionally get
an OutOfMemory exception as it tried to redraw. I found
that I could fix the problem by hiding the listview whilst
the columns were being resized, then showing it again
when finished. This fixed the crashing, which suggested
that the problem was graphics-related. I ended
up abandoning the whole idea to be on the safe side.

Now I am wondering if my OutofMemory menu crash
is related to this same issue. ie possibly a bug in
the listview's graphics memory allocation, which only shows
up occasionally when you have a large no. of items ??

thanks again Cor :-)
Steve