|
Look at this interesting thing...
If I minimize the program which is using about 16000K of memory, the memory usage reduces to about 4000K.
Is the Windows Task Manager reliable to check the memory usage ?
Somebody told me that it is not the correct place to check it because the windows task manager doesn't show the memory usage of an application. It only shows its "working set", which is the memory reserved by Windows to my application.
He also told me that the Windows changes the "working set" as it believes that it is needed to review the balance.
Do you guys suppose it is correct ?
If not, how can I measure the real memory usage of my application ?
And how could I check if my application has any kind of memory leak issue ? Is there any tool to check it for C++ Builder ?
|
|
|
|
|
caoctaviano wrote: Somebody told me that it is not the correct place to check it because the windows task manager doesn't show the memory usage of an application. It only shows its "working set", which is the memory reserved by Windows to my application.
He also told me that the Windows changes the "working set" as it believes that it is needed to review the balance.
I agree.
The outside world knows how much memory the app holds, not how much it uses, the app itself (and its GC, if it has one) is the only one to know that.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
If you were using Visual C++, I'd point you at the C runtime or MFC leak detection support, or CodeProject's very own Visual Leak Detector[^]. As you're not...mmmmm. Tricky. Commercial options, obviously - Purify[^] or BoundsChecker[^] or AQTime[^] (memory checker AND profiler!). If you were using Linux, there's valgrind[^]. OS X? MallocDebug, leaks[^] or Instruments[^].
BCB on WIndows...mmmm - I really don't know!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I've downloaded the trial version of AQTime v6 to check the memory usage and I've noticed that the item "Reserved Virtual Memory" ( Class Name column ) related to the app ( Module Name column ) raises constantly during the execution of the app.
May it be a problem related to program code or it is normal ?
I'm using the Allocation Profiler on AQTime v6.
Carlos
|
|
|
|
|
caoctaviano wrote: May it be a problem related to program code or it is normal ?
Could be - but I can think of scenarios where it's perfectly normal behaviour. I've never used AQTime, so I don't really feel qualified to comment...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have a problem similar! What do you do to resolve?
Do you have any threads in your project ? Because in my project have some threads and data base connection with postgres.
Thanks!
|
|
|
|
|
Hey can anyone help me to plot the 3D graphs in C++ ??
Thanks in advance
suchitamanandhar@hotmail.com
|
|
|
|
|
SayamiSuchi wrote: Hey can anyone help me to plot the 3D graphs in C++ ??
Probably. What's your question?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
We all can't wait to help you...What's your doubt about?
BTW did you read forum guidelines [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You can try some third party tools or please check the Desktop Development section. you will get lots of help in that.
|
|
|
|
|
You don't need any third party components (never in Windows..)
Simply use the native Win32 Graph control
|
|
|
|
|
I have two specific keys available at the following location in registry
HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\INSTALLER\USERDATA\S-1-5-18\PRODUCTS\---CLASSID----\InstallProperties\
The above path is having classid with it.
How to read this and retrieve the value.
|
|
|
|
|
Venkat KR wrote: How to read this and retrieve the value.
Maybe you can use CRegKey[^]
|
|
|
|
|
Venkat KR wrote: How to read this and retrieve the value.
Start here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
//Open the registrey and check that is it writable
lRet=RegOpenKey(HKEY_LOCAL_MACHINE, strKeyPath,hKey);
//if lRet != ERROR_SUCCESS then go to read registrey
unsigned char* lpBufferValue = new unsigned char [dwSize];
unsigned long dwType = 0;
unsigned long dwSize = 0;
lpBufferValue = new unsigned char [dwSize];
ASSERT(lpBufferValue);
lRet = RegQueryValueEx(hKey,strValueName, NULL,dwType, lpBufferValue,dwSize);
// if dwSize is not 0 then it is success
// close registrey (either success or failure )
RegCloseKey(hKey);
I hope this will work.
It's not enough to be the best, when you have capability to be great..
|
|
|
|
|
//Open the registrey and check that is it writable
lRet=RegOpenKey(HKEY_LOCAL_MACHINE, strKeyPath,hKey);
//if lRet != ERROR_SUCCESS then go to read registrey
unsigned char* lpBufferValue = new unsigned char [dwSize];
unsigned long dwType = 0;
unsigned long dwSize = 0;
lpBufferValue = new unsigned char [dwSize];
ASSERT(lpBufferValue);
lRet = RegQueryValueEx(hKey,strValueName, NULL,dwType, lpBufferValue,dwSize);
// if dwSize is not 0 then it is success
// close registrey (either success or failure )
RegCloseKey(hKey);
I hope this will work.
It's not enough to be the best, when you have capability to be great....
|
|
|
|
|
I am creating an app where I have CListBox object. I call .AddString() to add 10 string to the list. After the list is initialized, I want to update some of the string data in the list. How to do ? I reviewed all the class member of CListBox and I do not see any type of update string method. The only way I see to do this type of operation is to use Add/Delete methods. There must be a bette way Please help, so much time wasted on this class.
|
|
|
|
|
Perhaps your requirements call for using a ListView rather than a ListBox?
|
|
|
|
|
Hi, thank you for the reply I will look into ListView. As I found out yesterday ListBox is very good for what I am trying to do. I'm basically trying to create a window that is a comm monitor. I have 10 CAN message I receive at a very high rate 20-100ms that I want to display. With CListBox I am getting "flickering" and I know the app is probably getting tons of Window messaging !!
|
|
|
|
|
CodeMacDaddy wrote: The only way I see to do this type of operation is to use Add/Delete methods.
That's about it. Do you have an aversion to this approach?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Adding and removing items repeatedly may affect the performance of the application. You might want to use a CListCtrl[^].
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
For a small list (small number of items) the Add/Delete will work (maybe add a CWnd::LockWindowUpdate rto prevent flickering)
You could also use the list box in "virtual mode".
This signature was proudly tested on animals.
|
|
|
|
|
Hi again,
I got another one. This time regarding mutexes. I am using the following locking routine:
HANDLE Thread::Lock( const char* name )
{
wchar_t buffer[FILENAME_MAX];
mbstowcs_s( NULL, buffer, FILENAME_MAX, name, FILENAME_MAX-1 );
HANDLE hMutex = CreateMutex(NULL,
FALSE,
buffer);
if (!hMutex)
{
return NULL;
}
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
}
WaitForSingleObject(hMutex, INFINITE);
return hMutex;
}
Now I found out that my locking mechanism does not work properly. And the thing is this: Thread 1 calls the Lock()-function. A Mutex is created and everything is fine. While it is locked the same thread actually (which is an error, but that´s how I found out) calls the Lock()-function again with the same name parameter. CreateMutex returns a DIFFERENT handle this time but the GetLastError query returns ERROR_ALREADY_EXISTS. But since it is a different handle WaitForSingleObject() grants access again, before the first Unlock() call occured.
So how does this work. Shouldn´t I get the same handle everytime I call CreatMutex() with the same parameters? Otherwise I get a new handle everytime and nothing is really ever locked.
Thanks again.
Souldrift
|
|
|
|
|
Souldrift wrote: But since it is a different handle WaitForSingleObject() grants access again, before the first Unlock() call occured.
Or since the handle is to the same mutex and the thread already has a lock on it the wait call does not block.
Not all synchronization objects work the same, particularly when you lock them multiple times in the same thread. There are different object because they are designed to work differently.
Also I seriously recommend one obtains a good book on multi-threading if one intends to learn the subject.
|
|
|
|
|
The main problem here is that you are returning a local variable. In addition, every time your function is called, it creates a new mutex handle (referencing the same mutex.) You are leaking handles like crazy.
To properly use a mutex you need to first create it (and you don't need to do a conversion from a char to wide string--just call CreateMutexA.) The locking is done separately.
BTW, only use mutexes if you are synchronizing between processes or you have to have multiple waits on a lock, otherwise use critical sections.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|