|
Hi,
I tracked my exception problem to OUT OF MEMORY as I hadn't checked the return code from my CDialog::Create
Since I am doing Interprocess communication with a console program I allocate most of my objects on the Heap
So my question(s) now are
1) How can I tell how much heap storage is allocated to my app
2) Is there anyway from the Visual Studio debugger to tell how much heap I have used
The only information I have is from task manager in the memory coulmn (private working set) says I am using 2,540 for my process
My laptop has 3.00 gb I think I could go up to 4 gb though I don't think adding more memory is the root of the problem
thanks
|
|
|
|
|
Hi,
ForNow wrote: 1) How can I tell how much heap storage is allocated to my app
1) Derrive All classes from a common abstract class. 'MyCommonClass'
2) Declare a Static property: 'QWORD MyCommonClass::m_qw_AllocMem=0;'
3) Declare a Pure Virtual Function 'DWORD MyCommonClass::_GetSize()=0'
4) Write a Contructor:'MyCommonClass::MyCommonClass(){m_qw_AllocMem+=_GetSize();}'
5) Write a Destructor:'MyCommonClass::~MyCommonClass(){m_qw_AllocMem-=_GetSize();}'
ForNow wrote: 2) Is there anyway from the Visual Studio debugger to tell how much heap I have
used
Well I'm using C++ 5.00, and, No, there is none there.
ForNow wrote: The only information I have is from task manager in the memory coulmn (private
working set) says I am using 2,540 for my process My laptop has
3.00 gb I think I could go up to 4 gb though I don't think adding more memory is
the root of the problem
Well I dont'know what you are trying to achieve. I take it that you've only one thread. Also, you will get the same message if you exhaust the stack. This can happen if you have an Not Terminating recursion. (A recursion is a routine calling itself)
A 'RichEdit' is not an easy control to set up. It relies on COM Objects to do its bidding. I have always avoided this control for that reason. COM objects, by their nature are linked at Runtime, the details of the actual DLL and Function to be called extracted from the Registry. That latter process is notoriouisly slow, and consumes large amounts of memory.
Also, some libaries simply report 'Out Of Memory' when any other error occurs, which the author did not document further.
Hope this was usefull,
Bram van Kampen
|
|
|
|
|
What do you put in the body of _GetSize() ?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
Richard Andrew x64 wrote: What do you put in the body of _GetSize() ?
In the Base Class we have _GetSize()=0; (Pure Virtual Function)
In each of the Derrived classes:
int MyClass::_GetSize(){return sizeof(*this);}
Because the function is declared Pure Virtual in the base class, the compiler will insist that an implementation of a derrived class includes the function declaration and definition for _GetSize() (i.e.: One cannot 'forget' to include it.)
Regards
Bram.
Bram van Kampen
|
|
|
|
|
Brilliant!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
1. See the comments in MSDN on operator new[^].
2. Not that I am aware of, as I have never run into this problem.
It may well be that you are going in the wrong direction with this issue. You need to go back to your application and try to determine why you are running out of memory, rather than trying to find out how much may be available.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
I have 4 CWinThread objects which are wrappers for 4 CAsyncObjects I commented out the creation of these objects and still I get an out of memory when trying to do the create for the modeless dialog box
I am going to start post to see if there are any plug-in to the Visual Studio debugger which track Heap storage
Thanks
|
|
|
|
|
You have changed your explanation of the problem from your original post; where did this modeless dialog come into the equation? As I said above, you really need to spend some time going through your code to find out where (and why) you are using all this storage.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Sorry I was getting exceptions and wasn't sure truth is I didn't check the return codes
I just did some reading in a Book MFC internals and there is a section there about memory leaks using the CMemoryState functions
I am going track the heap memory I use
Thanks
|
|
|
|
|
OnSize(UINT nType, int cx, int cy)
{
IsWindow(xxx.GetSafeHwnd())
{
}
}
|
|
|
|
|
What does this mean and why have you posted it to me?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I have a working static splitter frame and need to retrieve pane based on CFormView.
I am getting assertion in GetPane MFC (4.0 / VC 6.0) function , and only on this type of splitter pane.
Plain CView works fine.
I did search on similar problems and it looks like the CFormView is the problem.
Any suggestion how to fix this?
Please no “ upgrade to xxxx”, not an option.
CWnd* CSplitterWnd::GetPane(int row, int col) const
{
ASSERT_VALID(this);
CWnd* pView = GetDlgItem(IdFromRowCol(row, col));
ASSERT(pView != NULL); // panes can be a CWnd, but are usually CViews
return pView;
}
Your help is as allways appreciated.
Cheers Vaclav
|
|
|
|
|
|
Hello
This is my first post, so excuse me if its in the wrong place, I need to reference a public class within a c# dll, Let me set the scene,
lets call the c# dll 2 and the c++ DLL 1, Within dll 1 i have an int main(void) and I have referenced DLL 2 in the project, I have referenced the namespace in DLL 2 thus using namespace startProc, within that I have two classes the class i wish to get to is called Processstarter, within there there is a public static void run(args1,args2)
When i try and access run from within the in main(void)I get an error "Error c3861:Run: Identifier Not found", Please forgive me as I'm new to C++, I prefer c# instead.
Does this make sense what I'm trying to do?
All i want to do is call a method in a class in a namespace in a c# dll.
Help!!!
|
|
|
|
|
|
gs_murphy@ntlworld.com wrote: Does this make sense what I'm trying to do? No, you cannot call C# code from C++ unless you have built it as managed code. Also, having a main() function in a DLL makes no sense.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
hi,
I have a VC++ application accessing MSSQL database via web services. I need to generate some summary reports and I thought of using Crystal Report. But I could not add a Crystal Report Object template into the VC++ project, there is no template to choose from in the Add->New Item. How should I go about to add Crystal Report in my VC++ project? I could add a Crystal Report in a new C# project, the Crystal Report template could be found in Add->New Item->Reporting.
I have searched the internet but could not find any information pertaining to this query? There were similar questions being asked, but not answered.
Greatly appreciate if anyone can provide me some advice or point me to some sites where I can get a kickstart. I have been stucked for about a week... and I need to generate the report real soon...
Thanks!
|
|
|
|
|
Once I've test myself an application with Crystal Report 6 (is the version that I have at my job) ... and goes pretty well ... if you send me an email, I will send you a demo project ... is about four files that I couldn't put here ....
|
|
|
|
|
I try follow code :
private:
float Plus(float a, float b){return a + b;}
float Minus(float a, float b){return a - b;}
float Multiply(float a, float b){return a * b;}
float Divide(float a, float b){return a / b;}
float SwitchWithFunctionPointer(float a, float b, float(*PointToFunction)(float,float));
and implementation:
float CTestBeginnerView::SwitchWithFunctionPointer(float a, float b, float(*PointToFunction)(float,float))
{
return PointToFunction(a,b);
}
void CTestBeginnerView::OnHelpTestfunctionpointer()
{
float f = SwitchWithFunctionPointer(4,8,&Plus); }
I get this error :
error C2276: '&' : illegal operation on bound member function expression
can you explain me why ? I reproduced the example from here[^]
|
|
|
|
|
high-level answer: the example was C, but you're writing C++.
low-level answer: you have written the functions as members of a class. in general, you can't do a plain pointer to a class member function.
one possible solution is to simply move those functions out of that class.
another possible solution is to make them static members of your class.
static float Plus(float a, float b){return a + b;}
|
|
|
|
|
Thank you very much, now it goes well ... best wishes !
|
|
|
|
|
Simply put, it's because you tried to get the address of a (non-static) member function.
It should work if you either:
- declare CTestBeginnerView::Plus as static
- remove the code from a class
Look-up thunking for a more in-depth discussion of the times that (1) is employed.
Here's a good discussion for now: Pointers to Member functions
|
|
|
|
|
1.declare CTestBeginnerView::Plus as static
is obviously my mistake, I try to point to an function that was not static ...
|
|
|
|
|
|
That was truly helpful.
|
|
|
|