|
My post was detailing the actual tab and combobox in the Project settings.
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
|
remove the _ATL_MIN_CRT preprocessor directive from your project settings (in Release build).
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
consider the following code snip of code
#include <map>
using namespace std;
typedef map<float,float> XY_DATA;
XY_DATA m_mapLines;
..
..
for(int i=0;i<100;i++)
m_mapLines[i]=i;
well the following assignment for the map is done
and a relative increase in memory consumed is observed.
OK
now for my problem
when i try to release the memory allocated using
m_mapLines.empty()
or
clear()
eventhough when i try map.size() i get zero.
there is no memory reduction in the taskmamager
what should i do to reduce the memory consumed by the map after emptying all its contents???
|
|
|
|
|
First of all, you are only dealing with a very small amount of memory in the example code that you have shown. 100 integers or 400 bytes plus whatever the map requires internally to manage the state of the data. This is much less than the amount of memory required in one virtual page of memory that is probably between 4 - 16 KB on your machine.
The memory manager often will allocate a new page and cache the excess memory in order to make newer requests more efficient later. So even though you have cleared out your map, the memory manager is still going to hold on to the memory.
There is really nothing that you can or need to do. What you are seeing is not a problem.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
You could try the swap trick
XY_DATA().swap(m_mapLines);
I think that's the correct syntax.
Todd Smith
|
|
|
|
|
Hi,
One problem solved another problem appears. THis time i encountered a problem that has no good explantion for it. I got an error when trying to open a connection to the ADO. The code that i have written is:
Code
try
{
//THROW_ERR( CoInitialize(NULL) );
THROW_ERR( CoCreateInstance(CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER, IID_IADOConnection, (LPVOID*)&m_pConnection) );
THROW_ERR( m_pConnection->Open(m_bsDataSource, m_bsUserName, m_bsPassword, adOpenUnspecified) );
}
catch (HRESULT hr)
{
PopupErrorMessage(hr);
return FALSE;
}
I tried out the code in the debug mode and it stopped at the line where it calls the 'Open' function.
The error message is:
Program:C:\temp\project\project.exe
Module:
File:i386\chkesp.c
Line: 42
The Value of the ESP was not properly saved across function call. This us usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
I have included the 'adoid.h' and 'adoint.h' in the 'stdafx.h' file. I even included the 'adoid.lib' in my project setting. What is the root cause of this problem and how to solve it??
Need your help..
thanks in advance.
leonwoo
|
|
|
|
|
Hi,
I am a newbie in ATL and have a question that hope you can answer it. The question is that I am trying to convert a BSTR type variable into a LPCTSTR type. I used the _com_util to do it but when i compiled the program, errors appear. I created the ATL project using the ATL wizard and the error message i received was
--------------------------------------------------------------------------
The original source code:
STDMETHODIMP CIniLoader::GetPrivateProfileString(BSTR bsSection, BSTR bsEntry, BSTR *bsOutput)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
LPCTSTR lpSection = _com_util::ConvertBSTRToString(bsSection);
return S_OK;
}
The Error message
{C:\temp\Project\PlatformManager\IniLoader.cpp(45) : error C2653: '_com_util' : is not a class or namespace name
C:\temp\Project\PlatformManager\IniLoader.cpp(45) : error C2065: 'ConvertBSTRToString' : undeclared identifier}
----------------------------------------------------------------------
I tried to include the header file 'comutil.h' into the project and added an extra line 'using namespace _com_util' into the implementation but another different errors appeared.
--------------------------------------------------------------------------
Creating library Debug/PlatformManager.lib and object Debug/PlatformManager.exp
IniLoader.obj : error LNK2001: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(unsigned short *)" (?ConvertBSTRToString@_com_util@@YGPADPAG@Z)
Debug/PlatformManager.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
I have no idea which portion of the code went wrong...please help...
thanks in advance.
leonwoo
|
|
|
|
|
leonwoo wrote:
IniLoader.obj : error LNK2001: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(unsigned short *)" (?ConvertBSTRToString@_com_util@@YGPADPAG@Z)
Are you possibly passing it the string literal where it may need a pointer to it?
Have you looked at this MSDN page[^]
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
thanks for the link Nick. I have doubt in what this line is doing. Can you explain it. thanks.
#pragma comment(lib, "comsupp.lib")
leonwoo
|
|
|
|
|
leonwoo wrote:
I have doubt in what this line is doing. Can you explain it.
It is telling the compiler to search the comsupp.lib while linking.
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
The quickest way is to use a _bstr_t, which provides the character set conversion:
BSTR bs1 = ...;
_bstr_t bs2 ( bs1, true );
LPCTSTR psz = (LPCTSTR) bs2;
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
The quickest way is to use a _bstr_t, which provides the character set conversion:
Ok Mike, maybe you can clear this up for me, maybe (please):
What is the purpose (for example) of having all these different types/names for string like data types? After reviewing the MSDN article[^] here I see things like, LPCSTR , LPCTSTR , LPCWSTR , LPTSTR , LPWSTR , PCSTR , PCTSTR , etc.... I think you get the point. I understand these are names, but why in the hell are there so many, they seem to be so closely related to each other.
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
The LP and P prefixes mean the same thing these days. The difference is a leftover from the days when there were near and far pointers (L = long, indicating a far pointer).
I just posted an article about strings[^], and I have part 2 almost done which covers the various wrapper classes and how to convert among them.
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Michael Dunn wrote:
I just posted an article about strings[^], and I have part 2 almost done which covers the various wrapper classes and how to convert among them.
Thanks Mike, that's exactly what I was looking for, C++ keeps becoming more and more inviting every day.
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
thanks for the valuable knowledge sharing........
cheers
leonwoo
|
|
|
|
|
I am working on a ATL Com object. I want to ask what is the difference between ReleaseMinSize and ReleaseMinDependency. I observed that size of ReleaseMinDependency is much less that ReleaseMinSize. I am interested in both reducing size as well as distributing minimum DLL's with my DLL.
Can any one tell the difference
Ahsan
|
|
|
|
|
With RelMinSize your code links to atl.dll and the CRT DLLs. What I do is build RelMinDep so I don't have to worry about shipping other DLLs, then set the compiler optimizations to minimize size (default is maximize speed) and add the linker switch /opt:nowin98 which shaves a few more K off the binary's size.
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I did do a few worker/window threads with MFC but I don't have a clue where to start so I can use threads with ATL...
Can someone point me to a tutorial or some doc?
Thanks!
---------------
Concentrating on Ideas
http://www.edovia.com
|
|
|
|
|
There is no thread wrapper class, you just use _beginthread() or _beginthreadex() to create new threads.
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks Mike!
Although I get this error when trying to use _beginthread()
error C2664: '_beginthread' : cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void *)'
I did follow the example on MSDN, my function doesn't return any value but it won't work!!!
---------------
Concentrating on Ideas
http://www.edovia.com
|
|
|
|
|
As the error message says, your thread func has the wrong signature. It takes a void* (not void) and needs to be declared with the __cdecl calling convention.
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Wouldn't it be better to use CreateThread() to minimize the CRT (and perhaps elminate the need for it)?
--
Please state the nature of your medical emergency.
|
|
|
|
|
I don't think I've ever made a non-trivial ATL project that didn't use the CRT. I always use a string function, or an STL collection, or something. So I personally don't care about keeping the CRT out and saving what, 40-50K?
--Mike--
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
All I want to do is to use atlgdi.h but things get bad when I include atlapp.h. I can't get the project to compile, I always get this error:
unresolved externals... CAppModule or CServerAppModule...
Anyone has a bulletproof stdafx.h?
I'm going mad!
---------------
Concentrating on Ideas
http://www.edovia.com
|
|
|
|