languages csharp Memory Leak in C# 2.0 W/ Anonymous Delegates?
http://www.eggheadcafe.com/forumarchives/NETcsharp/Sep2005/post24005267.asp
Memory Leak in C# 2.0 W/ Anonymous Delegates? – bytes
http://bytes.com/groups/net-c/276123-memory-leak-c-2-0-w-anonymous-delegates
Choosing What To Lock On
http://www.yoda.arachsys.com/csharp/threads/lockchoice.shtml
Short but complete programs
http://www.yoda.arachsys.com/csharp/complete.html
A Timer class for C# Console Applications
http://www.mycsharpcorner.com/Post.aspx?postID=31
Locking memory and multiple timers? – bytes
http://bytes.com/groups/net-c/533034-locking-memory-multiple-timers
C#遍历文件夹及文件_耍猫的鱼
http://hi.baidu.com/bobo712/blog/item/570df12a85e1e42bd52af1d0.html
天极网—软件频道
http://www.chinabyte.com/20020122/214916.shtml
请问在C#的过程当中如何使用局部的静态变量? .NET技术 / C# – CSDN社区 community.csdn.net
http://topic.csdn.net/t/20020503/15/696086.html
c#中没有局部静态变量么?方法内的静态变量? .NET技术 / C# – CSDN社区 community.csdn.net
http://topic.csdn.net/t/20040713/16/3171049.html
用C#实现Ping程序_C#小站
http://hi.baidu.com/tcggy/blog/item/3d9567894b332cb20f2444d8.html
QuartzTypeLib.dll 文件_我的空间~我做住
http://hi.baidu.com/lxsunshuai/blog/item/7568dffa9721abd9b48f3192.html
Firefox 3地址栏技巧三则
http://www.3648.com/article/sort07/sort0177/sort0204/info-10064.html
Ubuntu中文论坛 • 查看主题 – firefox3.1搜索引擎没google的,, 添加也没发现.
http://forum.ubuntu.org.cn/viewtopic.php?f=73&t=147894&view=previous
Firefox 3 tips: 加入自定义的OpenSearch – Kukoo\’s Blog
http://www.kompakar.com.cn/kukoo/2008/07/26/add-opensearch-into-firefox/
Firefox扩展: Read it Later_深度思考,简单生活…
http://hi.baidu.com/cdcarbon/blog/item/a8086d3fb687e6ef54e723f2.html
Firefox 3 tips: 加入自定义的OpenSearch – Kukoo\’s Blog
http://www.kompakar.com.cn/kukoo/2008/07/26/add-opensearch-into-firefox/
在Firefox 3中添加淘宝网搜索引擎 – IT频道 – 21CN.COM
http://it.21cn.com/software/sygj/2008/08/14/5065234.shtml
Ubuntu中文论坛 • 查看主题 – 如何更改firefox的默认搜索引擎
http://forum.ubuntu.org.cn/viewtopic.php?t=54411
keyword.UR
firefox 更改默认搜索引擎_Davy\’s note
http://hi.baidu.com/updavy/blog/item/c1ee501b18c791d6ac6e7543.html
Memory Leak problems – Infragistics Forums
http://forums.infragistics.com/forums/t/16138.aspx
CodeDom and GenerateInMemory memory leak – VB.NET
http://www.techtalkz.com/vb-net/126333-codedom-generateinmemory-memory-leak.html
GC with memory leaks? – GameDev.Net Discussion Forums
http://www.gamedev.net/community/forums/topic.asp?topic_id=94358
Delegate Pattern?!? or memory leak? (OO, Patterns, UML and Refactoring forum at JavaRanch)
http://www.coderanch.com/t/98558/OO-Patterns-UML-Refactoring/Delegate-Pattern-or-memory-leak
IanG on Tap: Event Handlers, Circular References, and Alleged Memory Leaks
http://www.interact-sw.co.uk/iangblog/2004/07/07/circulareventrefs
CodeDom and GenerateInMemory memory leak
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.languages.vb/2007-10/msg00894.html
Did it with .NET – The Problem With Delegates
http://diditwith.net/2007/03/19/TheProblemWithDelegates.aspx
The Ideal Solution
The best solution to this problem is to introduce a notion of "weak delegates" into the CLR. A weak delegate would create a weak reference to its Target rather than a strong one. Then, when the Target is garbage collected, the runtime would remove the delegate from any delegate chains that it is currently a part of. And, if there are any direct references to the delegate, they would do nothing when invoked. I\’m not sure what the C# syntax would look like for such an animal. Maybe something like this:
SystemEvents.DisplaySettingsChanged += new weak EventHandler(ehDisplaySettingsChanged);
I am not the first person to suggest something like this. In fact, there have been several. Unfortunately, because the .NET framework will be built upon the 2.0 version of the CLR for the foreseeable future, there probably won\’t be anything added for quite some time (if ever).
So, we developers are forced to roll our own solution to this problem. There have been several attempts made and not all of them have been successful. It turns out that getting the right balance of efficiency, memory use and elegance is pretty tricky. Next time, we\’ll take an in-depth look at one potential solution that I\’ve found to be successful.
Does not calling EndInvoke *really* cause a memory leak ? : Common Language Runtime : .NET Development : MSDN Forums
http://social.msdn.microsoft.com/Forums/en-US/clr/thread/b18b0a27-e2fd-445a-bcb3-22a315cd6f0d/
Delegate Pattern?!? or memory leak? (OO, Patterns, UML and Refactoring forum at JavaRanch)
http://www.coderanch.com/t/98558/OO-Patterns-UML-Refactoring/Delegate-Pattern-or-memory-leak
Greg Schechter\’s Blog : Simulating “Weak Delegates” in the CLR
http://blogs.msdn.com/greg_schechter/archive/2004/05/27/143605.aspx
Rico Mariani\’s Performance Tidbits : Tracking down managed memory leaks (how to find a GC leak)
http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx
PerformanceCounter 基本介绍以及示例方法 – 点滴积累,融会贯通 – 博客园
http://www.cnblogs.com/xh831213/articles/1218234.html
用C#程序监控并显示CPU状态信息->>网页教学网Webjx.Com 提供最新最快的网页技术
http://www.webjx.com/htmldata/2007-07-18/1184726682.html
XGEN:Exchange 2000 Server 内存使用和 /3GB 开关
http://support.microsoft.com/kb/328882
WPF 性能分析工具
http://msdn.microsoft.com/zh-cn/downloads/aa969767.aspx
如何查看内存使用情况—使用Vadump – Managed空间 – 博客堂
http://cache.baidu.com/c?m=9d78d513d98712b8599dc2395254c321590a8f397a9192027ea78e55c33a0614506694e37a69415985926b6776fe1403f7a5652e62413de4db99d21199ec8f282d8a2129721d9b4216ce1aabca4125d620e709a8ed53&p=81769a4186cc47ac0e81c02b5f07&user=baidu
C#共享内存类 改进版_半天月·随笔 &line;&line; 拾遗
http://hi.baidu.com/bantianyue/blog/item/e97c8ed4aeacb406a18bb7a3.html
C#进程间共享内存,内存映象(MMF) – ICERAIN\’s tech BLOG – 博客园
http://www.cnblogs.com/doubaokun/archive/2008/11/27/1341918.html
共享内存操作类(C#源码)-UML软件工程组织-火龙果软件
http://www.uml.org.cn/net/200809013.asp
C#下的进程间的通讯 — 共享内存篇——奴隶
http://www.x2blog.cn/jinhong618/21581.html
C#共享内存实例 附源码_半天月·随笔 &line;&line; 拾遗
http://hi.baidu.com/bantianyue/blog/item/f175dfb4504a1d748bd4b2da.html
c# 进程间同步实现 进程之间通讯的几种方法 – 静水流深 – 博客园
http://www.cnblogs.com/sandy81/archive/2008/10/15/1311722.html
在.NET中使用命名管道完成进程间通信
http://www.hackhome.com/InfoView/Article_121029_3.html
使用微软消息队列实现C#进程间通信(1) – C#编程 – 技术应用 – 豆豆网
http://tech.ddvip.com/2007-11/119554606737754.html
Build a C# Named-Pipes Based Inter-Process,Inter-Machine Object Caching Service
http://www.eggheadcafe.com/articles/20060404.asp
.NET csharp Using NamedPipes in C#
http://www.eggheadcafe.com/software/aspnet/29482882/using-namedpipes-in-c.aspx
C#, .Net Framework: Build a C# Named Pipes Interprocess, inter-machine Cache Service
http://www.kinlan.co.uk/2006/04/build-c-named-pipes-interprocess-inter.html
CodeProject: Inter-Process Communication in .NET Using Named Pipes, Part 2. Free source code and programming help
http://www.codeproject.com/KB/threads/dotnetnamedpipespart2.aspx
在.NET中使用命名管道完成进程间通信_动网_社区论坛·开发者网络源动力
http://www.cndw.com/tech/program/2006041947315.asp
在.NET中使用命名管道完成进程间通信 – 软件工程 – 网络编程 – www.DevDao.com
http://www.devdao.com/Article/396126.htm
Windows中的Pipe – λ-calculus in C++Blogs – C++博客
http://www.cppblog.com/vczh/archive/2008/08/01/57697.html
Named Pipes – Sample code for new .NET 3.5 classes – nntpnews.net
http://www.nntpnews.net/f3634/named-pipes-sample-code-new-net-3-5-classes-4627358/
关于framework3.5中管道
http://topic.csdn.net/u/20080517/13/e97124dd-eba2-40e6-8e4b-d73e17083cbe.html
C#共享内存类改进版 – 半天月·随笔 &line;&line; 拾遗 – CSDNBlog
http://blog.csdn.net/zzh8845/archive/2008/11/22/3350150.aspx
C#共享内存实例 附源码 – 半天月·随笔 &line;&line; 拾遗 – CSDNBlog
http://blog.csdn.net/zzh8845/archive/2008/11/22/3349963.aspx
C# auto update – lundy的专栏 – CSDNBlog
http://blog.csdn.net/lundy/archive/2007/06/26/1666936.aspx
远程自动更新源码(C#版本) CSDN 下载频道
http://download.csdn.net/source/834477
饿郎原创-开源项目
http://www.jrgz2008.com/blog/post/opensource.html
饿郎原创-【原创程序】C#客户端软件自动升级程序
http://www.jrgz2008.com/blog/post/soft/AutoUpDate.html
在WinForm中使用Web Services 来实现 软件 自动升级( Auto Update ) (C# – Kevins_Leader的专栏 – CSDNBlog
http://blog.csdn.net/kevins_leader/articles/624680.aspx
在WinForm中使用Web Services 来实现 软件 自动升级( Auto Update ) (C# – Kevins_Leader的专栏 – CSDNBlog
http://blog.csdn.net/kevins_leader/articles/624680.aspx
自动更新程序源码下载(C#.Net) – jenry-云飞扬 – 博客园
http://www.cnblogs.com/jenry/archive/2006/09/26/477302.html
100分请教 C/S程序更新问题
http://topic.csdn.net/u/20070813/15/fe727341-5a69-4404-b79b-1009f040857b.html?1353246953
CodeGuru: An AutoUpdate Trick
http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c9331
C# Auto Update : Visual Studio Smart Device Development – Visual Basic and C# Projects : Smart Device Development : MSDN Forums
http://social.msdn.microsoft.com/forums/en-US/vssmartdevicesvbcs/thread/48b40777-e404-4a2d-b9ce-4ff54209e7b4/
CodeProject: Application Auto Update Revisited. Free source code and programming help
http://www.codeproject.com/KB/vb/Auto_Update_Revisited.aspx
转别人的用C#实现软件自动更新思路_快乐D小孩
http://hi.baidu.com/happybadbaby/blog/item/6e22e9e94cba673ab80e2d90.html
自动更新程序源码下载(C#.Net)_我的空间,我做主
http://hi.baidu.com/ruishicun/blog/item/ee661bfb6137d6274f4aeaa1.html
C# CS架构自动更新服务器端 自动生成 xml配置文件1_JAIMY
http://hi.baidu.com/jaimy%5Fjie/blog/item/b1a549bf9b57580e18d81fbd.html
C#WinForm App自动更新(Live Update)架构_java & .net营地(java&.net&javascript相关收集)
http://hi.baidu.com/czh0221/blog/item/d545d8ef46d81c33adafd5db.html
桌面上显示隐藏回收站(注册表)_天涯明月心
http://hi.baidu.com/he520888/blog/item/a9b16d97a29fc26e54fb9667.html
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\NonEnum]
"&leftsign;645FF040-5081-101B-9F08-00AA002F954E&rightsign;"=dword:00000001
菜鸟玩转SP手机_窝客
http://hi.baidu.com/%E7%AA%9D%E5%AE%A2/blog/item/8f46ea012c3d20011c958378.html
20071017 memory leak c++ new malloc CEGUI
http://www.yippeesoft.com
使用 memleak 检查和调试内存泄漏
http://blog.iyi.cn/hily/archives/2007/09/_memleak.html
memleak 的原理是利用 C 语言的宏调用来替代原有的函数调用,比如我们在代码中调用 malloc(s),实际是调用了:dbg_malloc(s),这个宏定义在 memleak.h 中给出:
#define malloc(s) (FILE_LINE, dbg_malloc(s))
memleak 维护了一个链表,在这个链表中保存着程序中对内存函数调用的记录,这些函数包括:malloc、calloc、realloc、free。每次调用这些函数时,就会更新这个链表。
有了这个表,我们就可以在适当的位置调用 memleak 提供的函数,显示一些重要的信息,包括 malloc、calloc、realloc、free调用的次数,申请及分配的内存数,调用的文件和位置等等,信息非常详细。有了这些功能,我们就很容易定位内存使用的错误源。
http://www.linuxquestions.org/questions/showthread.php?t=281830
"It\’s not an extra new-line, each line should be terminated by an "end of line" tag, and this is \\n under unix.
On MacOS, this used to be \\r, perhaps the reason why gcc is more tolerant on newer releases of this O/S."
– 有人思考过 –
"do you know real reason of that?"
– 马上就有人提出质疑 –
"There\’s probably still some ancient compilers out there (maybe even very old versions of GCC?) that want each line to end with a newline or else they crash. My guess is that GCC is just trying to help you make your code compatible with these dino\’s."
– 接着就有人提出自己的观点 –
"Actually, gcc warns about it because it has to according to the standard. Check out this link for a brief description: http://gcc.gnu.org/ml/gcc/2003-11/msg01568.html
If you have a compiler that doesn\’t warn you about the lack of a newline character then that compiler doesn\’t meet the standards. Burn the disc it came on and get a real compiler."
– 很快,依靠大家的力量,借助网络,答案浮出水面 –
"The C language standard says
A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character.
Since this is a "shall" clause, we must emit a diagnostic message for a violation of this rule.
This is in section 2.1.1.2 of the ANSI C 1989 standard. Section 5.1.1.2 of the ISO C 1999 standard (and probably also the ISO C 1990 standard)."
CEGUI(Crazy Eddie’s GUI http://www.cegui.org.uk)是一个自由免费的GUI库,基于LGPL协议,使用C++实现,完全面向对象设计。CEGUI开发者的目的是希望能够让游戏开发人员从繁琐的GUI实现细节中抽身出来,以便有更多的开发时间可以放在游戏性上。
CEGUI的渲染需要3D图形API的支持,如OpenGL或Direct3D。另外,使用更高级的图形库也是可以的,像是OGRE、Irrlicht和RenderWare,关键需求可以简化为二点:
1. 纹理(Texture)的支持
2. 直接写屏(RHW的顶点格式、正交投影、或者使用shader实现)
CEGUI(Crazy Eddie’s GUI http://www.cegui.org.uk )是一套开源的使用C++开发的游戏界面库, 基于LGPL协议. 它能减少游戏开发中繁琐而大量的UI开发工作量. 现有很多游戏开发都会利用或者是借鉴它.
在学习了解CEGUI之前, 先把CEGUI源代码的环境搭建起来. CEGUI使用了几套开源库Freetype(http://sourceforge.net/projects/freetype), Glut(http://www.opengl.org/resources/libraries/glut), Xerces(http://xml.apache.org). 更全的信息资料大家可以去相应的网站上面了解. 下载相关库或者源代码后, 先在IDE中设置好, 那么就可以先编译CEGUI.
注意在使用freetype库时, CEGUIBASE工程链接会报错,提示为CEGUIBase error LNK2001: 无法解析的外部符号 _otv_module_class. 解决方法是在Freetype工程中打开ftmodule.h文件, 把FT_USE_MODULE(otv_module_class)这句代码注释掉,然后重新编译既可.
使用 cegui 来制作界面 , 不论在何种平台下 , 有基本的三大步骤要做 :
1, 创建一个 CEGUI::Render 实例
2, 创建 CEGUI::System 对象
3, 调用各种方法来渲染用户界面
第一步 , 在我使用的 ogre 环境下使用以下代码来创建 CEGUI::Render 实例
Ogre3D
CEGUI::OgreCEGUIRenderer* myRenderer =
new CEGUI::OgreCEGUIRenderer(myRenderWindow);
第二步相当简单 , 可使用
new CEGUI::System(myRenderer);
第三步,基本上来讲,大部分平台下,如 direct3D, OpenGL, 我们在渲染循环的尾部调用
CEGUI::System::renderGUI 来开始界面的渲染。如果我们使用 ogre3d 引擎,这一步不需要
我们显示的执行。因为 ogre 引擎已经考虑了。
CEGUI ,全称 "Crazy Eddie\’s GUI System" ,是一个专门的用户界面库,开源并且免费,它支持 DirectX8 、 DirectX9 ,除了可以作为 OGRE 的界面外挂,还支持另一个免费开源的 3D 引擎 Irrlicht 。由于它功能的相对强大和灵活, OGRE 的开发团队一直在推荐 OGRE 用户使用这个 CEGUI 来开发用户界面,逐渐抛弃 OGRE 本身过于简陋的 GUI 插件。尤其是在行将到来的新版本 OGRE 1.5 的声明中特别强调了这一点,尽管这个版本仍然暂时保留内置 GUI 系统,但 OGRE 1.5 将会是最后一个保留内置 GUI 的版本。 OGRE 看来似乎将专注于向一个纯粹的、然而富于协作和扩展性的图形引擎发展,这应该得益于它的庞大的社群支持,使得很多事情可以通过外挂一些更专业的引擎来实现,物理引擎使用 ODE 、 Tokamak 、 NovodeX ,网络引擎使用 openTNL 、 RakNet 、 eNet ,声音引擎使用 FMod 、 OpenAL ,以及这个界面引擎,使用 CEGUI 。外挂现成模块的好处就是可以专注于一个方面,开发一个五脏俱全的游戏引擎并不是个容易的事情,市面上最负盛名的几个商业引擎的开发, Unreal 、Renderware 、 Lithtech ,往往要耗费数百人年,并且在这些商业引擎中同样会使用外挂的商业库,在这个年代,没有人可以从头创建一切。
debugging memory leaks on uClinux專案程式已經膨脹到超過 50 個 .c, 外加 link 一份超大 C++ binary object, 這麼大的程式要在uclinux 上debug memory leak還真麻煩……
<br />
<br />好啦, 我承認當初不應該輕易打破 portability原則, 搞得現在沒辦法在 x86 debug.
<br />
<br />uclibc 好像有提供一些支援, 看到了這個
<br /><em>>make menuconfig</em>
<br /><strong><em>uClibc development/debugging options</em></strong>
<br /><strong><em> Build malloc with debugging support </em></strong>
<br /><strong><em></em></strong>
<br />希望這招有效, 明天來驗證
<br />
20071017 memory leak c++ new malloc
http://www.yippeesoft.com
Linux下的一个很好的内存泄漏检测工具 CSDN Blog推出文章指数概念,文章指数是对Blog文章综合评分后推算出的,综合评分项分别是该文章的点击量,回复次数,被网摘收录数量,文章长度和文章类型;满分100,每月更新一次。
最近做项目时用到的--valgrind.
能检测
1)使用未初始化的内存
2)读/写已经被释放的内存
3)读/写内存越界
4)读/写不恰当的内存栈空间
5)内存泄漏
6)使用malloc/new/new[]和free/delete/delete[]不匹配。
最简单的使用: valgrind –leak=check=full 后跟执行文件。
如何在linux下检测内存泄漏
http://www-128.ibm.com/developerworks/cn/linux/l-mleak/
http://blog.linuxpk.com/3973/viewspace-781
一个跨平台的 C++ 内存泄漏检测器
malloc是动态分配内存,只负责分配内存.并未调用任何函数。因为string类比较复杂,在输入字符串中还存在内存需求,结构中还含有指针。malloc并不管这些指针指向何方。
new还要调用对象的构造函数,对对象有一个初步的初始化。其指针所指地址已准备好了。
——————————————————–
New
会调用构造函数
delete
会调用析构函数
malloc free只能申请和释放普通类型
——————————————————–
malloc给你一块完整的内存,然后什么事情都不作,只是给你内存,使用于C,然后具体使用(包括INIT等都是由其他代码完成的)
而NEW是C++的东西,适合产生类啊,数组等差别很大
假设用两种方法给一个包含10个string对象的数组分配空间,一个用malloc,另一个用new:
string *stringArray1 =
static_cast<string*>(malloc(10 * sizeof(string)));
string *stringArray2 = new string[10];
其结果是,stringArray1确实指向的是可以容纳10个string对象的足够空间,但内存里并没有创建这些对象。而且,如果你不从这种晦涩的语法怪圈(详见条款M4和M8的描述)里跳出来的话,你没有办法来初始化数组里的对象。换句话说,stringArray1其实一点用也没有。相反, stringArray2指向的是一个包含10个完全构造好的string对象的数组,每个对象可以在任何读取string的操作里安全使用。
假设你想了个怪招对stringArray1数组里的对象进行了初始化,那么在你后面的程序里你一定会这么做:
free(stringArray1);
delete [] stringArray2; // 参见条款5:这里为什么要加上个"[]"
调用free将会释放stringArray1指向的内存,但内存里的string对象不会调用析构函数。如果string对象象一般情况那样,自己已经分配了内存,那这些内存将会全部丢失。相反,当对stringArray2调用delete时,数组里的每个对象都会在内存释放前调用析构函数。
既然new和delete可以这么有效地与构造函数和析构函数交互,选用它们是显然的。
把new和delete与malloc和free混在一起用也是个坏想法。对一个用new获取来的指针调用free,或者对一个用malloc获取来的指针调用delete,其后果是不可预测的。大家都知道“不可预测”的意思:它可能在开发阶段工作良好,在测试阶段工作良好,但也可能会最后在你最重要的客户的脸上爆炸。
new/delete和malloc/free的不兼容性常常会导致一些严重的复杂性问题。举个例子,<string.h>里通常有个strdup函数,它得到一个char*字符串然后返回其拷贝:
char * strdup(const char *ps); // 返回ps所指的拷贝
在有些地方,C和C++用的是同一个strdup版本,所以函数内部是用malloc分配内存。这样的话,一些不知情的C++程序员会在调用strdup后忽视了必须对strdup返回的指针进行free操作。为了防止这一情况,有些地方会专门为C++重写strdup,并在函数内部调用了new,这就要求其调用者记得最后用delete。你可以想象,这会导致多么严重的移植性问题,因为代码中strdup以不同的形式在不同的地方之间颠来倒去。
C++程序员和C程序员一样对代码重用十分感兴趣。大家都知道,有大量基于malloc和free写成的代码构成的C库都非常值得重用。在利用这些库时,最好是你不用负责去free掉由库自己malloc的内存,并且/或者,你不用去malloc库自己会free掉的内存,这样就太好了。其实,在C++程序里使用malloc和free没有错,只要保证用malloc得到的指针用free,或者用new得到的指针最后用delete来操作就可以了。千万别马虎地把new和free或malloc和delete混起来用,那只会自找麻烦。
既然malloc和free对构造函数和析构函数一无所知,把malloc/free和new/delete混起来用又象嘈杂拥挤的晚会那样难以控制,那么,你最好就什么时候都一心一意地使用new和delete吧。
malloc只是分配空间.
new除了分配空间,还负责初始化.
free只负责释放空间.
delete除了释放空间,还负责析构.
需要包含头文件:
#i nclude <alloc.h>
或
#i nclude <stdlib.h>
函数声明(函数原型):
void *malloc(int size);
说明:malloc 向系统申请分配指定size个字节的内存空间。返回类型是 void* 类型。void* 表示未确定类型的指针。C,C++规定,void* 类型可以强制转换为任何其它类型的指针。
从函数声明上可以看出。malloc 和 new 至少有两个不同: new 返回指定类型的指针,并且可以自动计算所需要大小。比如:
int *p;
p = new int; //返回类型为int* 类型(整数型指针),分配大小为 sizeof(int);
或:
int* parr;
parr = new int [100]; //返回类型为 int* 类型(整数型指针),分配大小为 sizeof(int) * 100;
而 malloc 则必须由我们计算要字节数,并且在返回后强行转换为实际类型的指针。
int* p;
p = (int *) malloc (sizeof(int));
第一、malloc 函数返回的是 void * 类型,如果你写成:p = malloc (sizeof(int)); 则程序无法通过编译,报错:“不能将 void* 赋值给 int * 类型变量”。所以必须通过 (int *) 来将强制转换。
第二、函数的实参为 sizeof(int) ,用于指明一个整型数据需要的大小。如果你写成:
int* p = (int *) malloc (1);
代码也能通过编译,但事实上只分配了1个字节大小的内存空间,当你往里头存入一个整数,就会有3个字节无家可归,而直接“住进邻居家”!造成的结果是后面的内存中原有数据内容全部被清空。
malloc 也可以达到 new [] 的效果,申请出一段连续的内存,方法无非是指定你所需要内存大小。
比如想分配100个int类型的空间:
int* p = (int *) malloc ( sizeof(int) * 100 ); //分配可以放得下100个整数的内存空间。
另外有一点不能直接看出的区别是,malloc 只管分配内存,并不能对所得的内存进行初始化,所以得到的一片新内存中,其值将是随机的。
除了分配及最后释放的方法不一样以外,通过malloc或new得到指针,在其它操作上保持一致。
标签:c++, leak, malloc, mem, memory, new20070221 cvs out of memory
http://www.yippeesoft.com/
我在使用cvs签出某个大文件的时候总是提示“cvs [server aborted]: out of memory; can not reallocate 337641472 bytes 错误,CVS操作失败”
我服务器是1个G内存的,那个文件才300M怎么会这样呢。
我试验了229M的文件,OK。配置512M的笔记本
估计两个:
1、CVS SRV 版本
2、服务器 客户机的临时空间
资料:
cvs [server aborted]: out of memory
Tom Simons writes:
>
> When checking out a directory with large binary files, cvs fails with
> "out of memory". How can we get around this?
Don\’t store large binary files in a source control system.
You need to make more virtual memory available on the server. How you
do that is, of course, system specific. On Unix-like systems, you need
to make more swap space available.
-Larry Jones
It\’s SUSIE! It\’s a GIRL! Santa would understand! — Calvin
Is there a limit with big files (82 Mega) in CVS?
i\’ve got a problem with handling big files. I\’ve got a big tar file in a project. It\’s about 82 megabyte. I can import the file into the repository, but if i want to check out or export the module, i get the message from cvs server that he can not allocate enough space ("out of memory; can not allocate 82055169 bytes). Is there an option in cvs to be set???
)
Compiling a 64 bit version solved this problem for me.
At our site the problem was solved by adding more physical ram into the machine. We now have 2GB RAM and are able to add files with 600 MB (the biggest file we ever had)
——————————————————————————–
CVS does not impose any limitations on file size. The above error suggests that your CVS server requires more virtual memory, or is running out of disk space in the CVS server\’s temporary directory.
–Jhyslop 17:38, 28 Oct 2005 (EDT)
Terminated with fatal signal 11
This message usually indicates that CVS (the server, if you\’re using client/server mode) has run out of (virtual) memory. Although CVS tries to catch the error and issue a more meaningful message, there are many circumstances where that is not possible. If you appear to have lots of memory available to the system, the problem is most likely that you\’re running into a system-wide limit on the amount of memory a single process can use or a similar process-specific limit. The mechanisms for displaying and setting such limits vary from system to system, so you\’ll have to consult an expert for your particular system if you don\’t know how to do that.
I was testing a script and ran into this problem with 2.5.01 (Travis) Build
1976 and 2.5.01 (Travis) Build 1990.
When I issue a cvs log command on one of our very large binary files, I get
an out of memory error:
>cvs log uaMain2.exe
cvs [server aborted]: out of memory; can not reallocate 415236096 bytes
This is on our hot backup server which is running W2K3 Server, and has 1GB
of memory. VM is set to 1.5GB, and watching the task manager, CVSNT throws
the error when the PF hits 1.0GB (It\’s idling at 200MB).
On our primary server, which is running XP Pro SP1 with 1GB of memory and
2.0.41a this works fine (the repositories are copied from the primary to the
hot backup each night).
The client in both cases is 2.0.62.1817. The ,v file is 538MB with 37
revisions of 13MB each.
Crash with out of memory error
More information -
Just noticed how new this build is, so I downgraded to version 1.11.1.2, and
that fixed the problem. I\’m now able to use CVSNT without a problem.
Looks like this is a bug in 1.11.1.3.
标签:mem, memory1221 unknow unknown device Memory Stick
昨天不知道怎么回事,将Memory Stick 卡插入读取器后,WINXP 一点反应都没有,我过去看了看,发现设备管理器中根本没有认到该设备。
显示 UNKNOWN DEVICE。
但是我的情况是
安装为 unknown device ,正常的不能再正常了,无论我怎么安装 INTEL INF,重新指定驱动程序,都告诉我 找不到更加匹配的驱动程序
重启系统;删除设备;重新 GHOST 回来系统,也是一样的效果;无论是插入 16M 还是 128M 的卡,都是一样
正常设备:
位置 0 (USB Memory Stick Slot) 通用串行总线控制器 兼容 USB 存储设备 USB MASS STORAGE DEVICE
最后的解决办法:我在读卡器上面按了几下~~~然后重新刷新硬件~~ 晕倒~~~~~~~
按照正常情况下,如果出现问题,WINDOWS应该提示:
系统发现新硬件,并表示正在安装,系统提示:跟这台计算机连接的一个usb设备运行不正常,windows无法识别。
或者
操作系统是Windows 2000简体中文专业版,正常是不需要驱动的,系统可以自动识别,但是现在在插上移动硬盘后,系统显示发现新硬件,并开始安装驱动,但是在驱动安装过程结束后,系统提示安装驱动过程中,出现了有一个错误,而后我在“设备管理器”里查看,发现在“通用串行总线控制器”下,有一项为“USB DEVICE”的,前面还有黄色叹号。很明显,这个移动硬盘虽然被系统发现,但是却不能被正确的识别,所以这个移动硬盘无法使用。在驱动安装过程中,根本没有人为的干预,却出现安装驱动错误
比较典型的一些资料
今天买了一个摄像头.首先安装光盘带的驱动,重启后.将摄像头连接到usb口(该usb口平时插u盘正常使用)。系统发现新硬件,并表示正在安装,但过一会儿系统提示:跟这台计算机连接的一个usb设备运行不正常,windows无法识别。打开设备管理器发现新增unknown.device但在属性里发现没有为该设备安装的驱动程序,让windows搜索驱动也没找到。
最简单的理由,摄像头坏了 ;重装
我将线插在USB插口处,电脑显示“发现新硬件”,接着我按照说明书的步骤一步一步安装,但是最后确出现“向导无法为您的硬件找到比现在安装的软件更匹配的软件”。烧录卡的灯也一直是红色的,启动烧录程序,但是无法使用““““`
这个是情况是你第一次安装时没有安装没成功,你把原来的驱动卸载掉。( 然后重新安装!!!记住第一次安装完以后驱动以后显示“驱动程序安装成功”,这时还没完!!!!!等一会儿,系统会提示发现新的硬件,重复刚才的新硬件安装过程!!这样才是安装成功!!
[楼主][每日必看]
添加硬件试验过了,被提示设备运转正常,下面是贴图,请高手指教
很明显从c,d,e,f是我本地硬盘,在资源管理器和磁盘管理器里找不到任何关于移动硬盘的图标,唯一可以看到的就是在设备管理器里面的unknowndevice,我尝试过用别人的hpnc7000可以马上找到,别人的台式的也可以,为什么我找不到呢,奇怪的是我可以找到另外一个紫光的移动硬盘,真是出鬼了 修改于:2004-3-23 22:2:56
在计算机管理/磁盘管理,也找不到,但是每当插上,计算机都会有提示,发现新硬件,并且最后说可以正常使用,但是就在资源管理器里找不到。。。。见下图
Memory Stick
Memory Stick,即内存棒,是一种专利技术,它是由Sony公司1997年7月与Casio、Fujitsu、 Olympus、 Sanyo和 Sharp共同开发出的一种超微体积(口香糖大小)集成化电路的数字存储介质。它是一种相当于AA电池大小的闪存卡,采用10针连接器,专门用于一系列不同的音频、视频及电脑设备之间的信息传递。
Memory Stick被很多人称为香口胶存贮卡,因为其尺寸确实像一条香口胶:50mm x 21.5mm x 0.28mm,重4克。采用精致醒目的蓝色外壳(新的MG为白色),并具有写保护开关。 Memory Stick由Sony在日本的工厂生产,但存贮单元模块却并不是由Sony自己生产的,而是由第三方厂商提供,不过Sony拒绝透露是哪一家(也许就是签了Memory Stick授权协议的TI)。
和很多Flash Memory存贮卡不同,Memory Stick规范是非公开的,没有什么标准化组织(Sony认为没有必要进行行业标准化)。这个香口胶采用了Sony自己的外型、协议、物理格式和版权保护技术,要使用它的规范就必须和Sony谈判签定许可。目前所知道的是Memory Stick也包括了控制器在内,采用10针接口,数据总线为串行,最高频率可达20MHz,电压为2.7伏到3.6伏,电流平均为45mA。可以看出这个规格和差不多同一时间出现的MMC颇为相似。
记忆棒 MSA-4A MSA-8A MSA-16A MSA-32A MSA-64A
记忆容量 4MB 8MB 16MB 32MB 64MB
外壳尺寸
(长x阔x厚) 50×21.5×2.8毫米
净重 4克
记忆类型 快闪记忆(Flash Memory)
连接器 10 针
介面 串行接口
传送率 最高 20 MHz
存取速度 写存速度;最高 1.5 MB/秒
读取速度:最高 2.45MB/秒
电压 2.7 伏特- 3.6伏特
电能消耗 平均:45mA ;备用:最高130mA
配件 记忆棒套及标签