Memory leak when using ice with MFC?

Hello,I tried to use Ice in a MFC dialog base application, but the debugger always tell me some memory leak existed. What I do is just:

1. Use the app wizard to generat an dialog based application.
2. Include the <ice/ice.h> and set all the lib file path
3. change the projet property to use unicode, multithread, and RTTI

After I do that, I build the project and find NO memory leak, but when I:

4. add Ice::CommunicatorPtr as a class member of the xxApp

memory leak occurs:(
I don't know what can cause this problem,what I add is just a smart point?
Do I misuse ICE?

Comments

  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    How do you know that there is a memory leak? Ice has been checked for memory leaks with Purify.
  • _orchid__orchid_ Member
    I use VC7.1 to build my application. As I all know, in the debug mode, VC will trace the memory allocation and dump the leak memory when the application terminate. So when I close the application, the fallowing imformation appears in the output window:

    Detected memory leaks!
    Dumping objects ->
    {214} normal block at 0x003A8450, 32 bytes long.
    Data: <Starter.StartupT> 53 74 61 72 74 65 72 2E 53 74 61 72 74 75 70 54
    {213} normal block at 0x003A83F0, 32 bytes long.
    Data: <Starter.RouterPa> 53 74 61 72 74 65 72 2E 52 6F 75 74 65 72 50 61
    {212} normal block at 0x003A8390, 32 bytes long.
    Data: <Starter.Properti> 53 74 61 72 74 65 72 2E 50 72 6F 70 65 72 74 69
    {211} normal block at 0x003A8330, 32 bytes long.
    Data: <Starter.Password> 53 74 61 72 74 65 72 2E 50 61 73 73 77 6F 72 64
    {210} normal block at 0x003A82D0, 32 bytes long.
    Data: <Starter.Endpoint> 53 74 61 72 74 65 72 2E 45 6E 64 70 6F 69 6E 74
    {209} normal block at 0x003A8270, 32 bytes long.
    Data: <Starter.CryptPas> 53 74 61 72 74 65 72 2E 43 72 79 70 74 50 61 73
    {208} normal block at 0x003A8200, 48 bytes long.
    Data: <Starter.Certific> 53 74 61 72 74 65 72 2E 43 65 72 74 69 66 69 63
    {207} normal block at 0x003A8190, 48 bytes long.
    Data: <Starter.Certific> 53 74 61 72 74 65 72 2E 43 65 72 74 69 66 69 63
    {206} normal block at 0x003A8120, 48 bytes long.
    Data: <Starter.Certific> 53 74 61 72 74 65 72 2E 43 65 72 74 69 66 69 63
    {205} normal block at 0x003A80B0, 48 bytes long.
    Data: <Starter.Certific> 53 74 61 72 74 65 72 2E 43 65 72 74 69 66 69 63
    {204} normal block at 0x003A8050, 32 bytes long.
    Data: <Starter.Certific> 53 74 61 72 74 65 72 2E 43 65 72 74 69 66 69 63
    {203} normal block at 0x003A7FE0, 48 bytes long.
    Data: <Starter.Certific> 53 74 61 72 74 65 72 2E 43 65 72 74 69 66 69 63
    {202} normal block at 0x003A7F80, 32 bytes long.
    Data: <Starter.Certific> 53 74 61 72 74 65 72 2E 43 65 72 74 69 66 69 63
    {201} normal block at 0x003A7F20, 32 bytes long.
    Data: <Starter.Certific> 53 74 61 72 74 65 72 2E 43 65 72 74 69 66 69 63
    {200} normal block at 0x003A7EC0, 32 bytes long.
    Data: <Starter.Certific> 53 74 61 72 74 65 72 2E 43 65 72 74 69 66 69 63
    {199} normal block at 0x003A7E50, 48 bytes long.
    Data: <Starter.AddUserT> 53 74 61 72 74 65 72 2E 41 64 64 55 73 65 72 54
    {198} normal block at 0x003A7DF0, 32 bytes long.
    Data: <Router.Trace.Ser> 52 6F 75 74 65 72 2E 54 72 61 63 65 2E 53 65 72
    {197} normal block at 0x003A7D90, 32 bytes long.
    Data: <Router.Trace.Rou> 52 6F 75 74 65 72 2E 54 72 61 63 65 2E 52 6F 75
    {196} normal block at 0x003A7D30, 32 bytes long.
    Data: <Router.Trace.Cli> 52 6F 75 74 65 72 2E 54 72 61 63 65 2E 43 6C 69
    {195} normal block at 0x003A7CD0, 32 bytes long.
    Data: <Router.SessionMa> 52 6F 75 74 65 72 2E 53 65 73 73 69 6F 6E 4D 61
    {194} normal block at 0x003A7C70, 32 bytes long.
    Data: <Router.Server.Fo> 52 6F 75 74 65 72 2E 53 65 72 76 65 72 2E 46 6F
    {193} normal block at 0x003A7C00, 48 bytes long.
    Data: <Router.Server.Th> 52 6F 75 74 65 72 2E 53 65 72 76 65 72 2E 54 68
    {192} normal block at 0x003A7B90, 48 bytes long.
    Data: <Router.Server.Th> 52 6F 75 74 65 72 2E 53 65 72 76 65 72 2E 54 68
    {191} normal block at 0x003A7B30, 32 bytes long.
    Data: <Router.Server.Th> 52 6F 75 74 65 72 2E 53 65 72 76 65 72 2E 54 68
    {190} normal block at 0x003A7AD0, 32 bytes long.
    Data: <Router.Server.En> 52 6F 75 74 65 72 2E 53 65 72 76 65 72 2E 45 6E
    {189} normal block at 0x003A7A70, 32 bytes long.
    Data: <Router.Server.Ba> 52 6F 75 74 65 72 2E 53 65 72 76 65 72 2E 42 61
    {188} normal block at 0x003A7A10, 32 bytes long.
    Data: <Router.PrintProx> 52 6F 75 74 65 72 2E 50 72 69 6E 74 50 72 6F 78
    {187} normal block at 0x003A79B0, 32 bytes long.
    Data: <Router.ThreadPoo> 52 6F 75 74 65 72 2E 54 68 72 65 61 64 50 6F 6F
    {186} normal block at 0x003A7950, 32 bytes long.
    Data: <Router.ThreadPoo> 52 6F 75 74 65 72 2E 54 68 72 65 61 64 50 6F 6F
    {185} normal block at 0x003A78F0, 32 bytes long.
    Data: <Router.ThreadPoo> 52 6F 75 74 65 72 2E 54 68 72 65 61 64 50 6F 6F
    {184} normal block at 0x003A7890, 32 bytes long.
    Data: <Router.Endpoints> 52 6F 75 74 65 72 2E 45 6E 64 70 6F 69 6E 74 73
    {183} normal block at 0x003A7830, 32 bytes long.
    Data: <Router.Client.Fo> 52 6F 75 74 65 72 2E 43 6C 69 65 6E 74 2E 46 6F
    {182} normal block at 0x003A77C0, 48 bytes long.
    Data: <Router.Client.Th> 52 6F 75 74 65 72 2E 43 6C 69 65 6E 74 2E 54 68
    {181} normal block at 0x003A7750, 48 bytes long.
    Data: <Router.Client.Th> 52 6F 75 74 65 72 2E 43 6C 69 65 6E 74 2E 54 68
    {180} normal block at 0x003A76F0, 32 bytes long.
    Data: <Router.Client.Th> 52 6F 75 74 65 72 2E 43 6C 69 65 6E 74 2E 54 68
    {179} normal block at 0x003A7690, 32 bytes long.
    Data: <Router.Client.En> 52 6F 75 74 65 72 2E 43 6C 69 65 6E 74 2E 45 6E
    {178} normal block at 0x003A7630, 32 bytes long.
    Data: <Router.Client.Ba> 52 6F 75 74 65 72 2E 43 6C 69 65 6E 74 2E 42 61
    {177} normal block at 0x003A75D0, 32 bytes long.
    Data: <Router.AllowCate> 52 6F 75 74 65 72 2E 41 6C 6C 6F 77 43 61 74 65
    {176} normal block at 0x003A7570, 32 bytes long.
    Data: <Router.AcceptCer> 52 6F 75 74 65 72 2E 41 63 63 65 70 74 43 65 72
    {175} normal block at 0x003A7510, 32 bytes long.
    Data: <Trace.TopicManag> 54 72 61 63 65 2E 54 6F 70 69 63 4D 61 6E 61 67
    {174} normal block at 0x003A74B0, 32 bytes long.
    Data: <Trace.Subscriber> 54 72 61 63 65 2E 53 75 62 73 63 72 69 62 65 72
    {173} normal block at 0x003A7450, 32 bytes long.
    Data: <TopicManager.Pro> 54 6F 70 69 63 4D 61 6E 61 67 65 72 2E 50 72 6F
    {172} normal block at 0x003A73F0, 32 bytes long.
    Data: <TopicManager.End> 54 6F 70 69 63 4D 61 6E 61 67 65 72 2E 45 6E 64
    {171} normal block at 0x003A7390, 32 bytes long.
    Data: <Publish.Endpoint> 50 75 62 6C 69 73 68 2E 45 6E 64 70 6F 69 6E 74
    {170} normal block at 0x003A7330, 32 bytes long.
    Data: <Server.Passphras> 53 65 72 76 65 72 2E 50 61 73 73 70 68 72 61 73
    {169} normal block at 0x003A72D0, 32 bytes long.
    Data: <Server.Overrides> 53 65 72 76 65 72 2E 4F 76 65 72 72 69 64 65 73
    {168} normal block at 0x003A7260, 48 bytes long.
    Data: <Server.Overrides> 53 65 72 76 65 72 2E 4F 76 65 72 72 69 64 65 73
    {167} normal block at 0x003A7200, 32 bytes long.
    Data: <Server.Overrides> 53 65 72 76 65 72 2E 4F 76 65 72 72 69 64 65 73
    {166} normal block at 0x003A7190, 48 bytes long.
    Data: <Server.Overrides> 53 65 72 76 65 72 2E 4F 76 65 72 72 69 64 65 73
  • _orchid__orchid_ Member
    {165} normal block at 0x003A7130, 32 bytes long.
    Data: <Server.Overrides> 53 65 72 76 65 72 2E 4F 76 65 72 72 69 64 65 73
    {164} normal block at 0x003A70D0, 32 bytes long.
    Data: <Server.CertPath*> 53 65 72 76 65 72 2E 43 65 72 74 50 61 74 68 2A
    {163} normal block at 0x003A7070, 32 bytes long.
    Data: <Client.Passphras> 43 6C 69 65 6E 74 2E 50 61 73 73 70 68 72 61 73
    {162} normal block at 0x003A7010, 32 bytes long.
    Data: <Client.Overrides> 43 6C 69 65 6E 74 2E 4F 76 65 72 72 69 64 65 73
    {161} normal block at 0x003A6FA0, 48 bytes long.
    Data: <Client.Overrides> 43 6C 69 65 6E 74 2E 4F 76 65 72 72 69 64 65 73
    {160} normal block at 0x003A6F40, 32 bytes long.
    Data: <Client.Overrides> 43 6C 69 65 6E 74 2E 4F 76 65 72 72 69 64 65 73
    {159} normal block at 0x003A6ED0, 48 bytes long.
    Data: <Client.Overrides> 43 6C 69 65 6E 74 2E 4F 76 65 72 72 69 64 65 73
    {158} normal block at 0x003A6E70, 32 bytes long.
    Data: <Client.Overrides> 43 6C 69 65 6E 74 2E 4F 76 65 72 72 69 64 65 73
    {157} normal block at 0x003A6E10, 32 bytes long.
    Data: <Client.Handshake> 43 6C 69 65 6E 74 2E 48 61 6E 64 73 68 61 6B 65
    {156} normal block at 0x003A6DB0, 32 bytes long.
    Data: <Client.CertPath*> 43 6C 69 65 6E 74 2E 43 65 72 74 50 61 74 68 2A
    {155} normal block at 0x003A6D50, 32 bytes long.
    Data: <Registry.Trace.S> 52 65 67 69 73 74 72 79 2E 54 72 61 63 65 2E 53
    {154} normal block at 0x003A6CF0, 32 bytes long.
    Data: <Registry.Trace.O> 52 65 67 69 73 74 72 79 2E 54 72 61 63 65 2E 4F
    {153} normal block at 0x003A6C90, 32 bytes long.
    Data: <Registry.Trace.N> 52 65 67 69 73 74 72 79 2E 54 72 61 63 65 2E 4E
    {152} normal block at 0x003A6C30, 32 bytes long.
    Data: <Registry.Trace.A> 52 65 67 69 73 74 72 79 2E 54 72 61 63 65 2E 41
    {151} normal block at 0x003A6BD0, 32 bytes long.
    Data: <Registry.Server.> 52 65 67 69 73 74 72 79 2E 53 65 72 76 65 72 2E
    {150} normal block at 0x003A6B70, 32 bytes long.
    Data: <Registry.Interna> 52 65 67 69 73 74 72 79 2E 49 6E 74 65 72 6E 61
    {149} normal block at 0x003A6B10, 32 bytes long.
    Data: <Registry.Interna> 52 65 67 69 73 74 72 79 2E 49 6E 74 65 72 6E 61
    {148} normal block at 0x003A6AB0, 32 bytes long.
    Data: <Registry.Dynamic> 52 65 67 69 73 74 72 79 2E 44 79 6E 61 6D 69 63
    {147} normal block at 0x003A6A50, 32 bytes long.
    Data: <Registry.Client.> 52 65 67 69 73 74 72 79 2E 43 6C 69 65 6E 74 2E
    {146} normal block at 0x003A69F0, 32 bytes long.
    Data: <Registry.Admin.E> 52 65 67 69 73 74 72 79 2E 41 64 6D 69 6E 2E 45
    {145} normal block at 0x003A6990, 32 bytes long.
    Data: <Registry.Admin.A> 52 65 67 69 73 74 72 79 2E 41 64 6D 69 6E 2E 41
    {144} normal block at 0x003A6930, 32 bytes long.
    Data: <Node.Trace.Serve> 4E 6F 64 65 2E 54 72 61 63 65 2E 53 65 72 76 65
    {143} normal block at 0x003A68D0, 32 bytes long.
    Data: <Node.Trace.Adapt> 4E 6F 64 65 2E 54 72 61 63 65 2E 41 64 61 70 74
    {142} normal block at 0x003A6870, 32 bytes long.
    Data: <Node.Trace.Activ> 4E 6F 64 65 2E 54 72 61 63 65 2E 41 63 74 69 76
    {141} normal block at 0x003A6810, 32 bytes long.
    Data: <Node.ThreadPool.> 4E 6F 64 65 2E 54 68 72 65 61 64 50 6F 6F 6C 2E
    {140} normal block at 0x003A67B0, 32 bytes long.
    Data: <Node.PropertiesO> 4E 6F 64 65 2E 50 72 6F 70 65 72 74 69 65 73 4F
    {139} normal block at 0x003A57F0, 32 bytes long.
    Data: <Node.PrintServer> 4E 6F 64 65 2E 50 72 69 6E 74 53 65 72 76 65 72
    {138} normal block at 0x003A5790, 32 bytes long.
    Data: <Node.CollocateRe> 4E 6F 64 65 2E 43 6F 6C 6C 6F 63 61 74 65 52 65
    {136} normal block at 0x003A6610, 32 bytes long.
    Data: <UseSharedCommuni> 55 73 65 53 68 61 72 65 64 43 6F 6D 6D 75 6E 69
    {135} normal block at 0x003A65B0, 32 bytes long.
    Data: <ServiceManager.I> 53 65 72 76 69 63 65 4D 61 6E 61 67 65 72 2E 49
    {134} normal block at 0x003A6550, 32 bytes long.
    Data: <ServiceManager.E> 53 65 72 76 69 63 65 4D 61 6E 61 67 65 72 2E 45
    {133} normal block at 0x003A64F0, 32 bytes long.
    Data: <ServiceManager.A> 53 65 72 76 69 63 65 4D 61 6E 61 67 65 72 2E 41
    {132} normal block at 0x003A6490, 32 bytes long.
    Data: <PrintServicesRea> 50 72 69 6E 74 53 65 72 76 69 63 65 73 52 65 61
    {131} normal block at 0x003A6430, 32 bytes long.
    Data: <Warn.Connections> 57 61 72 6E 2E 43 6F 6E 6E 65 63 74 69 6F 6E 73
    {130} normal block at 0x003A63D0, 32 bytes long.
    Data: <Warn.AMICallback> 57 61 72 6E 2E 41 4D 49 43 61 6C 6C 62 61 63 6B
    {129} normal block at 0x003A6370, 32 bytes long.
    Data: <ThreadPool.Serve> 54 68 72 65 61 64 50 6F 6F 6C 2E 53 65 72 76 65
    {128} normal block at 0x003A6310, 32 bytes long.
    Data: <ThreadPool.Serve> 54 68 72 65 61 64 50 6F 6F 6C 2E 53 65 72 76 65
    {127} normal block at 0x003A62B0, 32 bytes long.
    Data: <ThreadPool.Serve> 54 68 72 65 61 64 50 6F 6F 6C 2E 53 65 72 76 65
    {126} normal block at 0x003A6250, 32 bytes long.
    Data: <ThreadPool.Clien> 54 68 72 65 61 64 50 6F 6F 6C 2E 43 6C 69 65 6E
    {125} normal block at 0x003A61F0, 32 bytes long.
    Data: <ThreadPool.Clien> 54 68 72 65 61 64 50 6F 6F 6C 2E 43 6C 69 65 6E
    {124} normal block at 0x003A6190, 32 bytes long.
    Data: <ThreadPool.Clien> 54 68 72 65 61 64 50 6F 6F 6C 2E 43 6C 69 65 6E
    {123} normal block at 0x003A6130, 32 bytes long.
    Data: <PrintAdapterRead> 50 72 69 6E 74 41 64 61 70 74 65 72 52 65 61 64
    {122} normal block at 0x003A60D0, 32 bytes long.
    Data: <Override.Timeout> 4F 76 65 72 72 69 64 65 2E 54 69 6D 65 6F 75 74
    {121} normal block at 0x003A6070, 32 bytes long.
    Data: <Override.Compres> 4F 76 65 72 72 69 64 65 2E 43 6F 6D 70 72 65 73
    {120} normal block at 0x003A6010, 32 bytes long.
    Data: <MonitorConnectio> 4D 6F 6E 69 74 6F 72 43 6F 6E 6E 65 63 74 69 6F
    {119} normal block at 0x003A5FB0, 32 bytes long.
    Data: <Logger.Timestamp> 4C 6F 67 67 65 72 2E 54 69 6D 65 73 74 61 6D 70
    {118} normal block at 0x003A5F50, 32 bytes long.
    Data: <Default.Protocol> 44 65 66 61 75 6C 74 2E 50 72 6F 74 6F 63 6F 6C
    {117} normal block at 0x003A5EF0, 32 bytes long.
    Data: <ConnectionIdleTi> 43 6F 6E 6E 65 63 74 69 6F 6E 49 64 6C 65 54 69
    {116} normal block at 0x003A5B28, 32 bytes long.
    Data: <setAdapterDirect> 73 65 74 41 64 61 70 74 65 72 44 69 72 65 63 74
    {115} normal block at 0x003A5DC0, 32 bytes long.
    Data: <::Ice::LocatorRe> 3A 3A 49 63 65 3A 3A 4C 6F 63 61 74 6F 72 52 65
    {114} normal block at 0x003A5E90, 32 bytes long.
    Data: <::Ice::ObjectNot> 3A 3A 49 63 65 3A 3A 4F 62 6A 65 63 74 4E 6F 74
    {113} normal block at 0x003A5E20, 52 bytes long.
    Data: <`Y: [: `Y: > 60 59 3A 00 A0 5B 3A 00 60 59 3A 00 CD CD CD CD
    {110} normal block at 0x003A5C70, 12 bytes long.
    Data: <| > 7C D7 14 10 02 00 00 00 00 CD CD CD
    {109} normal block at 0x003A5D50, 48 bytes long.
    Data: <::Ice::AdapterAl> 3A 3A 49 63 65 3A 3A 41 64 61 70 74 65 72 41 6C
    {108} normal block at 0x003A5CE0, 52 bytes long.
    Data: <`Y: [: `Y: > 60 59 3A 00 A0 5B 3A 00 60 59 3A 00 CD CD CD CD
    {105} normal block at 0x003A5AE0, 12 bytes long.
    Data: <l > 6C D7 14 10 02 00 00 00 00 CD CD CD
    {104} normal block at 0x003A5C10, 32 bytes long.
    Data: <::Ice::AdapterNo> 3A 3A 49 63 65 3A 3A 41 64 61 70 74 65 72 4E 6F
    {103} normal block at 0x003A5BA0, 52 bytes long.
    Data: < \: `Y: ^: > E0 5C 3A 00 60 59 3A 00 20 5E 3A 00 CD CD CD CD
    {100} normal block at 0x003A5A98, 12 bytes long.
    Data: <\ > 5C D7 14 10 02 00 00 00 00 CD CD CD
    {99} normal block at 0x003A5A40, 24 bytes long.
    Data: < Q > 10 51 13 00 FF FF FF FF 00 00 00 00 00 00 00 00
    {98} normal block at 0x003A59D0, 52 bytes long.
    Data: < Y: Y: Y: > D0 59 3A 00 D0 59 3A 00 D0 59 3A 00 CD CD CD CD
    {97} normal block at 0x003A5960, 52 bytes long.
    Data: < \: [: ^: > E0 5C 3A 00 A0 5B 3A 00 20 5E 3A 00 CD CD CD CD
    {96} normal block at 0x003A58F0, 48 bytes long.
    Data: < P > F0 50 13 00 FF FF FF FF 00 00 00 00 00 00 00 00
    {95} normal block at 0x003A58A8, 12 bytes long.
    Data: <HW: HW: PX: > 48 57 3A 00 48 57 3A 00 50 58 3A 00
    {94} normal block at 0x003A5850, 24 bytes long.
    Data: < P > D0 50 13 00 FF FF FF FF 00 00 00 00 00 00 00 00
    {92} normal block at 0x003A5748, 12 bytes long.
    Data: < X: X: > A8 58 3A 00 A8 58 3A 00 CD CD CD CD
    {91} normal block at 0x003A5700, 12 bytes long.
    Data: < HW: > CD CD CD CD 48 57 3A 00 01 00 00 00
    {90} normal block at 0x003A5690, 48 bytes long.
    Data: <0123456789ABCDEF> 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46
    {89} normal block at 0x003A5640, 20 bytes long.
    Data: <@V: @V: @V: > 40 56 3A 00 40 56 3A 00 40 56 3A 00 CD CD CD CD
    {88} normal block at 0x003A55E8, 28 bytes long.
    Data: < P > 90 50 13 00 FF FF FF FF 00 00 00 00 00 00 00 00
    Object dump complete.

    I don't know whether it's VC debugger's problem, But when I write the simple console application without any MFC support, just like the examples in the cookbook :) , I havn't met the same problem. So I get confused:(
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    Hmm... sorry, but I'm afraid I don't know anything about this memory leak detector. The output seems to be very cryptic, i.e., I have no idea what the tool complains about.

    As I said, Ice has been checked with Purify, which is one of the most widespread memory leak detection tools. I'm pretty sure that there are no memory leaks in Ice, and that the reported memory leaks are fake.

    If you can point me to any specific instance where you think Ice has a memory leak, I would be happy to look at it. But from the debug output, it's impossible to tell what VC7.1 complains about.
  • _orchid__orchid_ Member
    I'm just afraid that there are some system resources aquire and release conflicts between Ice and MFC. If not, that will be fine. I don't care what debugger says.:rolleyes:

    An Other Question is about Freeze::map. I use Freeze to generate a simple StringIntMap and write a simple test. It seems that I can't find on the map instance after I erase something from it. If I do this, the program will hang up. The fallowing is the main program:

    int main (int argc, char* argv[])
    {
    Ice::CommunicatorPtr communicator = Ice::initialize(argc, argv);
    Freeze::ConnectionPtr connection = Freeze::createConnection(communicator, "db");

    {
    StringIntMap map(connection, "simple");

    map.clear();
    Ice::Int i;
    StringIntMap::iterator p;

    for (i = 0; i < 26; i++)
    {
    std::string key(1, 'a' + i);
    map.insert(std::make_pair(key, i));
    }

    p = map.find("z");
    assert(p != map.end());
    map.erase(p);

    //program will hang on this sentence
    p = map.find("a");
    }

    connection->close();
    communicator->destroy();
    }
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hello,

    I don't know either why you're getting these cryptic message from VC++ ... if you could e-mail a small test-case (with a project file), I'll try to find out!

    But I can explain the Freeze hang, self deadlock really). We did our best to make Freeze as easy to use a possible, but Berkeley DB imposes some constraints!
    Each iterator maps to a Berkeley DB cursor. If you don't use transactions, each Berkeley DB cursor is a "locker"; with transactions, each transaction is a locker.
    p = map.find("z");
    assert(p != map.end());
    map.erase(p);
    
    opens a Berkeley DB cursor with a write-lock on some database page (or pages).

    Later
    map.find("a");
    
    opens a new Berkeley DB cursor (and locker) which attempts to acquire a read lock on the same page (because you're unlucky or your database is really small).
    For Berkeley DB, everything is fine: one locker which holds no lock is waiting for some locks held by another locker. It does not see that the thread waiting is needed release the first locker.

    The solution I'd recommend is to use a transaction:
    #include <Freeze/TransactionsHolder.h>
    ...
    
    TransactionHolder txHolder(connection);
    
    // read and write map
    
    txHolder.commit();
    

    Another less appealing solution is to close your iterator/Berkeley DB cursor before the find():
    p = map.end();
    p = map.find("a"); 
    

    To reduce the likelyhood of such self-deadlocks, write operations on Map automatically close outstanding iterators (in both C++ and Java). So you won't self-deadlock if you read (even with cursors) and then write. However read operations do not close iterators: such behavior would be unexpected and would probably break some algorithm.

    Cheers,
    Bernard
  • _orchid__orchid_ Member
    Thanks very much! I think now I get more idea on Freeze:D

    I did some more test later yesterday, and found that the debugger will also complain in a console application when trying to using MFC together with Ice. I write a small demo to show this, but, how can I send it to you?
  • _orchid__orchid_ Member
    ok, now the attach file:cool:
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hello,

    I tried your demo and saw this ugly debug output in my Visual Studio .NET environment.
    Since this demo does not make any Ice-call (it just links with the Ice library), it's obviously not showing runtime leaks in Ice; it's really reporting static variables that allocate dynamic memory on construction and do not release this memory before the Microsoft memory tracker runs (if they ever do).

    Most of them are static std::string objects in Ice, for example:
    Data: <Server.CertPath*> 53 65 72 76 65 72 2E 43 65 72 74 50 61 74 68 2A 
    
    correspond to the "Server.CertPath*" string in src/Ice/PropertiesI.cpp.

    We're researching the best way to eliminate this ugly debug output.

    Cheers,
    Bernard
Sign In or Register to comment.