I am using TeeChart Pro v2013.0.1.4.131120 32bit ActiveX in an MFC application. There are 15 chart windows dynamically created on a dialog running on a UI thread and all of the charts windows get constantly updated by messages from the main thread. I am encountering the following issues:
An abnormal message box with "2." written inside constantly pops up once after the chart windows are created and updated.
Although at regular interval I am freeing the data for each chart with the following code I find that memory is continuously getting accumulated.
This is the code I'm using:
long sz = pchart_->GetSeriesCount();
for (int i = 0; i <= sz; ++i) {
pchart_->Series(i).Clear();
}
pchart_->RemoveAllSeries();
Can anyone please help/ highlight me regarding what is going wrong here?
Related
I have an old C program for displaying caller ID called YAC. Fortunately, the author Jensen Harris provided the source.
15 years ago, I modified the source to turn on the monitor if the computer was awake but the monitor was off. The code below worked well, turning on the monitor and making the caller ID message visible on the screen.
// TG - add a call to turn on the monitor if it is sleeping.....
SendMessage(hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
Recently the behavior has changed (presumably a Windows update changed something)
Now when a Caller ID message should be displayed, the monitor turns on (as evidenced by the LED), but the screen remains black. The monitor remains in the black-screen condition for a few seconds, then turns off again.
What additional or different call is now required to cause Windows to activate the display and show the desktop? Possibly this could be forced by sending a mouse move, but is there a better way?
EDIT:
I have implemented the following additional code to press and release ESC. I was unable to find a good example of a relative mouse move of 1 pixel, so I used an example for keyboard. I will test and see if it is effective.
INPUT inputs[2];
UINT uSent;
// reference: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput
ZeroMemory(inputs, sizeof(inputs));
inputs[0].type = INPUT_KEYBOARD;
inputs[0].ki.wVk = VK_ESCAPE;
inputs[1].type = INPUT_KEYBOARD;
inputs[1].ki.wVk = VK_ESCAPE;
inputs[1].ki.dwFlags = KEYEVENTF_KEYUP;
uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
EDIT2 - I can confirm this approach does work to cause the monitor to display video, but of course has the potential for side-effects as any keyboard or mouse action would. I would still be interested in learning of a pure API function that works to fully wake the system like SC_MONITORPOWER used to.
I've been trying to find a memory leak on iOS and i'm 99% it is either in a TScrollBox or in a TChart. The action that leads to the crash is simple scrolling back and forth across the TChart. The app behaves well in Win32 and memory useage is stable.
The crash cause on iOS is EXC_RESOURCE -> myappname[5548] exceeded mem limit: ActiveHard 1400MB (fatal) per Xcode Console.
To exclude my spaghetti code as the culprit i created a simple project to reproduce the error and it crashes too. Below are snips from the Xcode Console output. I get tons of assertions, then the Received memory warning, then the iOS kernal kills my app (Project1).
default 20:28:26.180333 -0500 assertiond [Project1:7693] Activate assertion: <BKProcessAssertion: 0x12b0102c0; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:…8EA7F5E94DD5>
default 20:28:26.180542 -0500 assertiond [Project1:7693] Setting jetsam priority to 10 [0x10108]
default 20:28:26.182151 -0500 assertiond [Project1:7693] Deactivate assertion: <BKProcessAssertion: 0x12b0102c0; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:…8EA7F5E94DD5>
default 20:28:26.182312 -0500 assertiond [Project1:7693] Setting jetsam priority to 10 [0x10100]
default 20:28:26.183307 -0500 assertiond [Project1:7693] Remove assertion: <BKProcessAssertion: 0x12b0102c0; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:…8EA7F5E94DD5>
default 20:28:32.609723 -0500 Project1 Received memory warning.
Then a short time later i see the following console message:
default 20:28:45.881914 -0500 kernel EXC_RESOURCE -> Project1[7693] exceeded mem limit: ActiveHard 1400 MB (fatal).
My crash test app is a simple Firemonkey app built in C++ Builder 10.3.2.
A) Put a TPanel on the form (Panel1).
B) Put a TScrollBox on Panel1 (ScrollBox1). Set its align to Contents.
C) Put a TLayout on ScrollBox1 (Layout1). Set its align to None. Set its width to 2100.
D) Put a TChart on Layout1. Set its height to 200, width 7300. Set its align to None.
E) Add a TToolBar to Form1 and put a TButton on it.
F) Then put this code in the TButton's click event:
Form1->Layout1->Position->X = 0;
Form1->ChartTest->Position->Y = 0;
Form1->ChartTest->Position->X = 0;
TLineSeries *series1 = new TLineSeries(Form1);
TLineSeries *series2 = new TLineSeries(Form1);
TLineSeries *series3 = new TLineSeries(Form1);
TLineSeries *series4 = new TLineSeries(Form1);
series1->Color = claBlue;
series2->Color = claRed;
series3->Color = claBlueviolet;
series4->Color = claAqua;
double x, y;
for (int i = 0; i < 1000; i++) {
x = i;
y = Random(5000);
series1->AddXY(x,y);
y = Random(5000);
series2->AddXY(x,y);
y = Random(5000);
series3->AddXY(x,y);
y = Random(5000);
series4->AddXY(x,y);
}
Form1->ChartTest->AddSeries(series1);
Form1->ChartTest->AddSeries(series2);
Form1->ChartTest->AddSeries(series3);
Form1->ChartTest->AddSeries(series4);
G) And now, with your iOS device connected to your mac and Xcode Console open, filter the Console output on "Project1" if that is what you named it. Then run the app and scroll backwards/forwards and/or up/down (also change orientation if you want back and forth). You will see tons of assertions. Eventually (takes around 2-3 minutes of this harassment to make it crash) it will eat up enough memory that it crashes.
I think the memory leak is in the TeeChart most likely, maybe in the TScrollBox?
thanks,
russ
The memory leak is in the TChart. I created another simple project with no scrollbox and i added a timer that moves the TChart up and down every 0.1 seconds. After 2-3 minutes it crashes on memory error on iOS with no user input after clicking Button1 to start things off. This crash occurs with no scrolling or any interaction - just the chart wiggling around.
Testing the app on Win32 works fine - memory is stable and not growing.
So, i'm hoping there is something obvious in how i create the chart that is the deficiency - i really don't want to abandon ship as Steema charts are so flexible. I've also posted to the Steema forum's but due to low volume there i'm posting here too.
Any ideas? Note i'm also using a licensed version of TeeChart Standard VCL/FMX released May 30, 2019 - Build 2019.27.190530. I also ran a test case where the chart is stationary (no user input and no timer event moving the chart around) and no crash. It has to do with the chart being rejiggered somehow. I tried Form1->ChartTest->AutoRepaint = false; but had no effect. The zipped test project is here: Project1a
thanks,
russ
UPDATE: The memory leak bug is present in TeeChart Standard build 2019.27.190530 but is not present in the free/lite version that comes stock with Rad Studio 10.3.2 as of now (version v2016.17.160129).
I'm working on a small educational piece of work, I create a window and its supposed to cover the entire monitor. However "special" areas are not being covered as seen in the screnshot at bottom. My window is a solid red with no menu bar scroll bar etc, is there anyway to make this cover the top menu bar and the dock. In my screenshot I am testing on Ubuntu and Mint, this is consistent behavior on Gtk OS's I need to be ablve ot set my window so it covers all things is this possible?
I tried gdk_window_fullscreen but it's not doing anything, not even fullscreen, do you think its because I'm running this function from another thread? How would I know if this function needs to be run from the main thread?
Incomplete coverage on Ubuntu:
Incomplete coverage on Mint:
Code Tried
A frameless window is opened using Firefox code from main thread:
var aEditorDOMWindow = Services.ww.openWindow(null, core.addon.path.content + 'panel.xul', '_blank', 'chrome,width=1,height=1,screenX=0,screenY=0', null);
Now after load of it completes then the GdkWindow* of this window is obtained on the main thread and passed to another thread as a string
The thread now takes the string to GdkWindow* then that to GtkWindow*
var gdkWinPtr = ostypes.TYPE.GdkWindow.ptr(ctypes.UInt64(aHwndStr));
var gtkWinPtr = ostypes.HELPER.gdkWinPtrToGtkWinPtr(gdkWinPtr);
The thread then executes gtk_window_set_keep_above because if there was another app was focused it will focus this guy, and it will keep him on top of existing full screen windows
var rez_topIt = ostypes.API('gtk_window_set_keep_above')(gtkWinPtr, true);
The thread used to then run gtk_window_present but I removed it as I noticed it would crash the app, this was the code:
var rez_focus = ostypes.API('gtk_window_present')(gtkWinPtr);
EXPERIMENTAL STUFF I tried but it didnt work to make the window cover the special UI:
ostypes.API('gdk_window_set_type_hint')(gdkWinPtr, ostypes.CONST.WINDOW_TYPE_HINT_SPLASHSCREEN);
ostypes.API('gtk_window_set_position')(gtkWinPtr, ostypes.CONST.GTK_WIN_POS_NONE);
var geom = ostypes.TYPE.GdkGeometry();
geom.max_width = aOptions.fullWidth;
geom.max_height = aOptions.fullHeight;
var rez_geo = ostypes.API('gtk_window_set_geometry_hints')(gtkWinPtr, null, geom.address(), ostypes.CONST.GDK_HINT_MAX_SIZE);
Now the thread work is done and it goes to main thread. Now the main thread uses firefox javascript to move the window to top left most origin (which i calculated earlier with Gdk calls) and also sets the width and height of this window to that calculated of all the monitors (i did this earlier with other gdk calls)
aEditorDOMWindow.moveTo(collCanMonInfos[0].xTopLeft, collCanMonInfos[0].yTopLeft);
aEditorDOMWindow.resizeTo(collCanMonInfos[0].nWidth, collCanMonInfos[0].nHeight);
This results in the window SOMETIMES covering all monitors, other times just the one it opened on. And it never covers special UI like the taskbar/dock/menubars.
If you can please advise on how to acheive a window that fully covers everything that would be very appreciated, I'm trying to teach some people some stuff and I ran into a mess.
Here is a youtube video of the addon I am making: https://www.youtube.com/watch?v=aJM5NQK67N4
I discontinued using gdk_fullscreen because when it worked intermittently it would not allow the window to expand outside the one monitor.
Panels are usually implemented with struts, and window managers can decide never to allow windows to cover them; that's one of the reasons why the whole idea of "full screen window" was introduced: it gives the window manager a hint that the window that requested to be full screen should cover all other windows; have no decorations; and also cover all eventual "system" components, like panels.
I am trying to do the standard - bind a list of data (including images) received from REST API calls in a very quick and smooth manner - a paradox in itself. I have 2 service calls that each take about 2 seconds to complete so I can async/await those, but based on the data returned, I then build other lists (observableCollection) in memory and bind them back to ListBox's in the page.
Problems:
This actual binding seems to lock up the UI thread, how can I asynchronously load my page - listBox by listBox (or even item by item) in a lazy fashion? I'd like to put a placeholder image in place and when finally bound, the placeholder is replaced by the bound image. Any ideas? Frameworks? Tools?
When binding the actual images, the other data in my DataTemplate, actually jumps around the screen while the Image is rendered. It looks terrible... I'd like to be able to, at the very least, bind the image first and then the other controls in the dataTemplate after? Anything that would make it appear a bit smoother would help.
Thanks in advance.
I suspect your problem in (2) will be solved with the placeholder image (assuming that it is the same size as the downloaded images).
I suspect that your "lock up" problem in (1) is that you are calling Wait or Result on a Task returned by an async method. In many cases, this results in a deadlock, as I explain in a recent MSDN article and on my blog.
I think what you really want is a way to start a Task and get a data-binding notification when it completes. I've developed a set of types (TaskCompletionNotifier) that helps out in this situation. Check out the end of my blog post on async properties for a sample. You may also be interested in my blog post on async constructors.
(1) If the list of items is large, binding them all at once will cause some stalling on the UI thread. One fix is to add the items a few at a time and pause so that the UI thread can get a new frame to the compositor before continuing.
public async void AddObjects(List<object> objects)
{
for(int i = 0; i < objects.Count; i++)
{
_myObservableCollection.Add(objects[i]);
if(i % 10 == 0) await Task.Delay(100);
}
}
(2) You should set a fixed width and height on the images in the DataTemplate, so that it does not change as the image is actually downloaded. Alternately, if you can fetch the width and height from your service in the API calls, bind the image width/height to those values before it gets downloaded.
I'm trying to setup multiple OpenGL (3.3) windows on the same program. I've created 2 windows, with the second one having the shared context of the first one (using hglrc[i] = wglCreateContextAttribsARB(hdc[n_windows], hglrc[0], ctxattribs) while the first one has 0 instead of hglrc[0]), with a simple loop like:
for(unsigned i = 0; i < n_windows; ++i)
{
wglMakeCurrent(hdc[i], hglrc[i]);
glClearColor((float)rand() / RAND_MAX, (float)rand() / RAND_MAX, (float)rand() / RAND_MAX, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
SwapBuffers(hdc[i]);
}
However only one window renders, and when I move a window to another screen, the Window that wasn't rendering now renders, and the other one stops rendering.
It's the first time I'm trying to open several OpenGL windows on the same application, with a shared context, so I might be doing something wrong. My code works perfectly with one window, and my old faithful gDEBugger doesn't show any error. Any idea on what I might be doing wrong?