kruege19
asked on
Excessive use of RAM with ClipBoard and ImageControl
I've got a problem that's driving me crazy. First, I was having problems getting MSChart to redraw without "blinking" in a very annoying manner. The solution I found to this was to copy the Chart to the clipboard and then display it with an image control:
frmMainScreen.StripChart.C hartData = arrStripChartData
Clipboard.Clear
frmMainScreen.StripChart.E ditCopy
frmMainScreen.imgChart.Pic ture = Clipboard.GetData
Clipboard.Clear
This totally cured the "blinking" problem but has also created another side effect. This method of refreshing the image is used about 2 times per second. I've been monitoring the system resources, and the RAM useage is increasing linearly with time. I have verified that it is the line:
frmMainScreen.imgChart.Pic ture = Clipboard.GetData
that is causing the problem. I believe that every time I copy the image from the clipboard to the image control, that a copy is being stored somewhere in RAM and I can not figure out why, where, or how to remove it.
Please help!
And as another added annoyance, when I'm running the program from within VB6, the memory never gets freed even when I exit the debug mode (only when I completely exit the VB environment). At least when I run a compiled .exe, it cleans up after itself when I exit.
frmMainScreen.StripChart.C
Clipboard.Clear
frmMainScreen.StripChart.E
frmMainScreen.imgChart.Pic
Clipboard.Clear
This totally cured the "blinking" problem but has also created another side effect. This method of refreshing the image is used about 2 times per second. I've been monitoring the system resources, and the RAM useage is increasing linearly with time. I have verified that it is the line:
frmMainScreen.imgChart.Pic
that is causing the problem. I believe that every time I copy the image from the clipboard to the image control, that a copy is being stored somewhere in RAM and I can not figure out why, where, or how to remove it.
Please help!
And as another added annoyance, when I'm running the program from within VB6, the memory never gets freed even when I exit the debug mode (only when I completely exit the VB environment). At least when I run a compiled .exe, it cleans up after itself when I exit.
Also puting the chart on the clipboard is very bad programming. What haappens if it is changed.
ASKER
I guess my newbie status will become evident here, but yes I do need more info:
How to I "clean up" the initial picture during refresh?
How would setting the Redraw property to True change the number of redraws? I'm explicity changing the image contents once every 500mS.
Locking the MSChart control before changing the data will stop the flickering? How do I "Lock" the control?
I should probably say more about what I'm doing. I'm creating a strip chart that scrolls across the screen displaying time values of certain parameters (like an EKG strip). So the data needs to move to the right with each time step and a new data point is added to the beginning of the series.
As for the clipboard issue, I totally agree that it is sloppy, but this software is only a demo of proposed features in our product, not software intended for use or distribution.
How to I "clean up" the initial picture during refresh?
How would setting the Redraw property to True change the number of redraws? I'm explicity changing the image contents once every 500mS.
Locking the MSChart control before changing the data will stop the flickering? How do I "Lock" the control?
I should probably say more about what I'm doing. I'm creating a strip chart that scrolls across the screen displaying time values of certain parameters (like an EKG strip). So the data needs to move to the right with each time step and a new data point is added to the beginning of the series.
As for the clipboard issue, I totally agree that it is sloppy, but this software is only a demo of proposed features in our product, not software intended for use or distribution.
ASKER
I guess my newbie status will become evident here, but yes I do need more info:
How to I "clean up" the initial picture during refresh?
How would setting the Redraw property to True change the number of redraws? I'm explicity changing the image contents once every 500mS.
Locking the MSChart control before changing the data will stop the flickering? How do I "Lock" the control?
I should probably say more about what I'm doing. I'm creating a strip chart that scrolls across the screen displaying time values of certain parameters (like an EKG strip). So the data needs to move to the right with each time step and a new data point is added to the beginning of the series.
As for the clipboard issue, I totally agree that it is sloppy, but this software is only a demo of proposed features in our product, not software intended for use or distribution.
How to I "clean up" the initial picture during refresh?
How would setting the Redraw property to True change the number of redraws? I'm explicity changing the image contents once every 500mS.
Locking the MSChart control before changing the data will stop the flickering? How do I "Lock" the control?
I should probably say more about what I'm doing. I'm creating a strip chart that scrolls across the screen displaying time values of certain parameters (like an EKG strip). So the data needs to move to the right with each time step and a new data point is added to the beginning of the series.
As for the clipboard issue, I totally agree that it is sloppy, but this software is only a demo of proposed features in our product, not software intended for use or distribution.
I think the Lock on the window will work best try this first.
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
LockWindowUpdate MSCHART1.hWnd
'Set your data
LockWindowUpdate False
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
LockWindowUpdate MSCHART1.hWnd
'Set your data
LockWindowUpdate False
To set the picture to nothing
set frmMainScreen.imgChart.Pic ture = Nothing
set frmMainScreen.imgChart.Pic ture = Clipboard.GetData
set frmMainScreen.imgChart.Pic
set frmMainScreen.imgChart.Pic
ASKER
Well, I tried both of the suggestions, and neither made a difference. Locking the window doesn't stop the Chart from "blinking" whenever it redraws (and its being redrawn every 500mS). I actually prefer to use the image technique anyway because it allows me to add labels (because they are actually being added to the image, and not the chart).
I also tried the Nothing command and it didn't do anything for the memory leak...
I also tried the Nothing command and it didn't do anything for the memory leak...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You may need to set property of imgChart namely
AutoRedraw to true.
Scalemode = vbPixels
AutoRedraw to true.
Scalemode = vbPixels
kruege19:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
Experts: Post your closing recommendations! Who deserves points here?
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
Experts: Post your closing recommendations! Who deserves points here?
Moderator, my recommended disposition is:
Accept JohnMcCann's comment(s) as an answer.
DanRollins -- EE database cleanup volunteer
Accept JohnMcCann's comment(s) as an answer.
DanRollins -- EE database cleanup volunteer
Also if you set the Redraw property imgChart to true. The number of redraws should be cut.
and one last though
If you lock the chart before update the flickering disapears.
If you wish for a clearer explanation just ask.