关于Android聊天界面中用使用adapter导致内存泄露的问题,目前不知道如何改善,大神帮忙看看 10C

之前一段时间使用一段时间老是导致内存升高,而且内存也不回收,一步一步的排除了很多地方,
到最后发现问题是出在adapter中,但是也不知道怎么改了。
大神帮看看哪些地方会导致内存泄露!
public void setmList(List mList) {
if (isgroup) {
isDiaplayNickName = SharePreferenceUtil.get_Boolean(mContext, groupid);
}
this.mList = mList;
}

public ChatMessageAdapter(Context mContext, List<ChatMessageEntity> mList, boolean isGroup, String groupId) {
    this.mContext = mContext;
    this.mList = mList;
    this.groupid = groupId;
    this.isgroup = isGroup;
    if (isGroup) {
        isDiaplayNickName = SharePreferenceUtil.get_Boolean(mContext, groupId);
    }
    decodeResource = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.head);
    imageLoader = new ImageLoader(mContext);
    chatLoader = new ImageChatLoader(mContext);
    fileUtils = new FileUtils();
    changeHandlers = new changeHandler(mContext);
    memoryCache = new MemoryCache();
    db = new DatabaseHelper(mContext);
    chatTypefaceSize = SharePreferenceUtil.getInt(mContext, ChatValue.CHAT_TYPEFACE_TAG, ChatValue.CHAT_TYPEFACE_KEY);
}

hoderView.chatToView.getRightWarnImg().setOnClickListener(new resendMessageOnClickListener(entity, hoderView.chatToView.getRightWarnImg()));
        hoderView.chatToView.getRightWebView().getTitleView().setOnLongClickListener(new OnCheckLongClickListener(entity, position, null));
        hoderView.chatToView.getRightWebView().getTitleView().setOnClickListener(new ShareLinkOnclick(entity, position));
        try {
            if (!Tool.instance().getString(entity.getContentUrl()).equalsIgnoreCase("")) {
                WebviewLoader.instance(mContext).displayWebview("http://" + HttpUtil.CHECK_URL + entity.getContentUrl(), hoderView.chatToView.getRightWebView());
                hoderView.chatToView.getRightWebView().getmMessage().setText(Tool.instance().getString(entity.getContent()));
            }
            if (!Tool.instance().getString(entity.getUrl()).equalsIgnoreCase("")) {
                ShowShareLinkView.instance(mContext).displayWebview(entity.getUrl(), Tool.instance().getString(entity.getContent()), hoderView.chatToView.getRightWebView());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

hoderView.chatToView.getRightWebView().setVisibility(View.GONE);
hoderView.chatToView.getRightImg().setVisibility(View.GONE);
hoderView.chatToView.getRightText().setVisibility(View.VISIBLE);
hoderView.chatToView.getRightWarnImg().setOnClickListener(new resendMessageOnClickListener(entity, hoderView.chatToView.getRightWarnImg()));
hoderView.chatToView.getRightText().setTextColor(mContext.getResources().getColor(R.color.black));
hoderView.chatToView.getRightText().setOnLongClickListener(new OnCheckLongClickListener(entity, position, null));

        hoderView.chatToView.getMessageLayout_right().setPadding(mContext.getResources().getDimensionPixelSize(R.dimen.font10),
                mContext.getResources().getDimensionPixelSize(R.dimen.font10),
                mContext.getResources().getDimensionPixelSize(R.dimen.font15),
                mContext.getResources().getDimensionPixelSize(R.dimen.font10));

        Spannable spannable = FaceConversionUtil.getInstace().getExpressionString(mContext, Tool.instance().getString(entity.getContent()));
        hoderView.chatToView.getRightText().setText(spannable);
    }

    hoderView.chatToView.getHeadIcon().setImageBitmap(decodeResource);
    imageLoader.DisplayImage(HttpUtil.HEADIMAGE_URL_60 + entity.getLoginuserid(), hoderView.chatToView.getHeadIcon(), true);


FaceConversionUtil是一个加载表情的外部工具类,而
imageLoader.DisplayImage是一个加载头像的工具类,还有ImageChatLoader是一个加载图片的工具类,这样写法中有哪些缺陷,我一步一步注销了看了,加载表情的工具类也会泄露一部分内存,大神们帮看看怎么改善,谢谢啦!FaceConversionUtil这个表情工具类我也是在网上搜到来用的
/**
* 得到一个SpanableString对象,通过传入的字符串,并进行正则判断
*
* @param context
* @param str
* @return
*/
public SpannableString getExpressionString(Context context, String str) {
SpannableString spannableString = new SpannableString(str);
// 正则表达式比配字符串里是否含有表情,如: 我好[开心]啊
String zhengze = "\[[^\]]+\]";
// 通过传入的正则表达式来生成一个pattern
Pattern sinaPatten = Pattern.compile(zhengze, Pattern.CASE_INSENSITIVE);
try {
dealExpression(context, spannableString, sinaPatten, 0);
} catch (Exception e) {
Log.e("dealExpression", e.getMessage());
}
return spannableString;
}
private void dealExpression(Context context,
SpannableString spannableString, Pattern patten, int start)
throws Exception {
Matcher matcher = patten.matcher(spannableString);
while (matcher.find()) {
String key = matcher.group();
// 返回第一个字符的索引的文本匹配整个正则表达式,ture 则继续递归
if (matcher.start() < start) {
continue;
}
String value = emojiMap.get(key);
if (TextUtils.isEmpty(value)) {
continue;
}
int resId = context.getResources().getIdentifier(value, "drawable",
context.getPackageName());
// 通过上面匹配得到的字符串来生成图片资源id,下边的方法可用,但是你工程混淆的时候就有事了,你懂的。不是我介绍的重点
// Field field=R.drawable.class.getDeclaredField(value);
// int resId=Integer.parseInt(field.get(null).toString());
if (resId != 0) {
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resId);
int dstWidth = context.getResources().getDimensionPixelSize(R.dimen.space_50);
int dstHeight = context.getResources().getDimensionPixelSize(R.dimen.space_50);
bitmap = Bitmap.createScaledBitmap(bitmap, dstWidth, dstHeight, true);
// 通过图片资源id来得到bitmap,用一个ImageSpan来包装
ImageSpan imageSpan = new ImageSpan(bitmap);
// 计算该图片名字的长度,也就是要替换的字符串的长度
int end = matcher.start() + key.length();
// 将该图片替换字符串中规定的位置中
spannableString.setSpan(imageSpan, matcher.start(), end,
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
if (end < spannableString.length()) {
// 如果整个字符串还未验证完,则继续。。
dealExpression(context, spannableString, patten, end);
}
break;
}
}
}

public static FaceConversionUtil getInstace() {
if (mFaceConversionUtil == null) {
mFaceConversionUtil = new FaceConversionUtil();
}
return mFaceConversionUtil;
}

6个回答

先考虑几个问题,getview是否复用了converview,创建的bitmap是否recycle了

helf19920825
helinfengg 你好,有复用的,创建的bitmap我也有recycle!
接近 4 年之前 回复

使用ImageLoad可以进行DisplayImageOptions 配置,包括它的一些缓存大小的设置等。使用webview加载也比较耗时,尽量少在adapter里面处理一些
耗时操作,可以处理好传递给它,毕竟它是用来绑定数据显示。执行在UI线程中

decodeResource = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.head);

创建的Bitmap,有回收么。我没有看到!decodeResource在使用时候回收掉,否则会占很大内存decodeResource.recycle();

decodeResource = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.head);

创建的Bitmap,有回收么。我没有看到!decodeResource在使用时候回收掉,否则会占很大内存decodeResource.recycle();
helf19920825
helinfengg 你好,我有回收的!
接近 4 年之前 回复

在adapter中尽量不进行耗时操作

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
关于Android内存泄露问题
前言这好像是我的第一篇博客,写着篇博客的初衷是因为自己在项目中被这个内存泄漏折磨到死,经过各种查找资料各种改,到最后终于有点好转了。其中的内容仅供参考。 内存泄漏(OOM)OOM : out of memory导致产生该异常的原因:长生命周期的对象持有短生命周期对象的引用。防止和减少OOM的相关措施: 数据库cursor游标没有关,使用完数据库一定要调用close释放资源 Adapter没有使用缓存
关于android内存泄露
说实话,我app做的不多,一半精力是在关注framework层和底层,最近有个人问我android内存泄露的问题,我就上网找了些资料看看,发现列举了很多条情况,1、2、3、4.....,而且很多都是抄袭,却没人真正去总结下根本原因,我说下自己的想法,欢迎讨论!       内存泄露可以说有两个根本原因:1、申请的资源没有被释放;2、长生命周期对象持有短寿命周期的对象的引用,使得gc无法回收。
使用Rxjava2导致的内存泄露问题
Rxjava是个异步库,其链式的api调用使用起来非常简洁,优雅,但是不做处理的话很容易出现内存泄露 内存泄露例子: 有个MainActivity,代码如下: class MainActivity : AppCompatActivity(), View.OnClickListener { override fun onCreate(savedInstanceState: Bu...
使用dialog导致内存泄露的问题
直接看导致泄露的log: 09-09 11:51:47.189 30236-30236/? E/WindowManager: android.view.WindowLeaked: Activity com.yinyutech.xiaolerobot.ui.activity.RegistActivity has leaked window com.android.internal.policy
内存泄露,帮忙看看
在做一个实时项目,内存增加太快~rnrn我用BoundChecker 检查到居然GDI+ 里Bitmap::FromHBITMAP有内存泄露~rnrn找了下,没发现有释放句柄的函数,而我 Bitmap *pBmp=Bitmap::FromHBITMAP(hBitmap,NULL); DeleteObject(hBitmap);rnrn还有什么解决的?
线程导致内存泄露问题
一个程序,在结束后output窗口会显示:rnthrdcore.cpp(166) : 1159 client block at 0x00C45800, subtype 0, 112 bytes long.rna CWinThread object at $00C45800, 112 bytes long什么意思?这个可能对除错有帮助。
内存泄露,请大神帮忙看下
[code=c]rnrn//类定义rnclass t_satObs rn public:rn t_satObs() rn t_satObs(const t_satObs& old) // copy constructor (deep copy)rn _staID = old._staID;rn _prn = old._prn;rn _time = old._time;rn for (unsigned ii = 0; ii < old._obs.size(); ii++) rn _obs.push_back(new t_frqObs(*old._obs[ii]));rn rn rn ~t_satObs() for (unsigned ii = 0; ii < _obs.size(); ii++) delete _obs[ii];rnrn std::string _staID;rn t_prn _prn;rn bncTime _time;rn std::vector _obs;rn;rn//出现问题的循环,如果加上这段代码,内存总是一直增加,可是没有发现什么问题呀!rnwhile(true)rnrn if (_rnx)rn rn long iSec = long(floor(obs._time.gpssec()+0.5));rn if (_rnx->samplingRate() == 0 || iSec % _rnx->samplingRate() == 0)rn rn _rnx->deepCopy(obs);rn rn _rnx->dumpEpoch(format, obs._time);rn rn rn//调用的函数rnvoid deepCopy(t_satObs obs) rn _obs.push_back(obs); //_obs为_rnx成员变量,定义:QList _obs;rnrnvoid dumpEpoch(const QByteArray& format, const bncTime& maxTime) rn QList obsList;rn QMutableListIterator mIt(_obs);rn while (mIt.hasNext()) rn t_satObs obs = mIt.next();rn if (obs._time < maxTime) rn obsList.push_back(obs);rn mIt.remove();rn rn rnrn[/code]rn大家费心了,如果能指出错误,会补分,跪谢!
BSTR导致内存泄露问题
在开发中对经常会由于粗心或遗漏而导致的BSTR内存泄露问题,特意研究并进行了整理,内部有教详细的说明,希望对大家能有所帮助。(注:涉及公司版权问题,仅供参考、谢谢)
DecimalFormat导致的内存泄露问题
昨天同事反馈在app无限循环new DecimalFormat时候,出现native heap不断增大的情况 应用在很多地方都会new DecimalFormat,简化版的代码如下: while(true) { new DecimalFormat(“0.000”); } dumpsys meminfo发现应用内存分布如下,native heap占用了278M 坐下看到这样代...
Android adapter设计模式三:聊天界面
1.效果图: 2.说明: getViewTypeCount返回的就是种类数目了; getItemViewType根据当然Item的position决定返回不同的整型变量。然后在getView中,根据消息的类型去加载不同的Item布局即可。3.源码:package com.example.android_robot_01;import java.util.List;import android.
关于android内存泄露那点事
相信大多安卓开发者在面试的时候如果面试官有点技术都会问到内存泄露和内存溢出的知识点,但是很多开发者都对这个不以为然,要么就是说我写的程序从来没遇到过这类问题,要么就是只知道bitmap是内存溢出的最常见原因,这样的问题都解决过等等。。。如果我是面试官那么我会认为你只值7K以下,那么一般要怎样才能回答的全面点呢,相信你认真看了这篇文章后,你就会觉得自己更上一层楼,对于面试官的这类问题也会很从容了
使用Handler导致内存泄露的解决方法
方法一:通过程序逻辑来进行保护。 1.在关闭Activity的时候停掉你的后台线程。线程停掉了,就相当于切断了Handler和外部连接的线,Activity自然会在合适的时候被回收。  2.如果你的Handler是被delay的Message持有了引用,那么使用相应的Handler的removeCallbacks()方法,把消息对象从消息队列移除就行了。  方法二:将Handler声明为静态
关于Android内存泄露的小结
1.具有close方法的对象切记调用close方法释放资源 2.动态注册的广播不使用后记得取消注册 3.bitmap的recycle方法 4.listView的Adapter中注意convertView的使用 5.handler 6.集合对象清理
关于Android内存泄露的说明
原视频地址:https://www.youtube.com/watch?v=6ryAYxLNpt8 Using MAT (Memory Analyzer Tool) to understand memory issues in your app 有条件的自行观看学习吧,我觉得这个视频讲得比较好,这篇文章就是对这个视频做了些总结记录 一.内存泄露的几种情况 1.Holding C
关于Android 内存泄露整理
内存泄漏: 简单粗俗的讲,就是该被释放的对象没有释放,一直被某个或某些实例所持有却不再被使用导致 GC 不能回收。 从基本的来讲 Java 内存分配策略 Java 程序运行时的内存分配策略有三种,分别是静态分配,栈式分配,和堆式分配,对应的,三种存储策略使用的内存空间主要分别是静态存储区(也称方法区)、栈区和堆区。 静态存储区(方法区):主要存放静态数据、全局 static 数据
[MongoDB]求大神帮忙看看是什么问题什么原因导致的
我删除lock文件删除journal文件后重启就恢复正常了,之前重启了也连接不了,下面贴出的是日志:(#号是隐藏的一些不重要的信息)rnrn运行环境: windows server 2008 ,mongodb 2.6.5rnrn2015-11-30T11:01:32.496+0800 [conn1486] VirtualProtect for C:/MongoDB/data/####/####.3 chunk 4772 failed with errno:1455 The paging file is too small for this operation to complete. (chunk size is 67108864, address is 4a90000000) in mongo::makeChunkWritable, terminatingrn2015-11-30T11:01:32.496+0800 [conn1486] ####.###### Fatal Assertion 16362rn############## rn2015-11-30T11:01:37.130+0800 [conn1511] *** unhandled exception 0x80000003 at 0x000000013FE82282, terminatingrn2015-11-30T11:01:37.130+0800 [conn1511] *** stack trace for unhandled exception:rn2015-11-30T11:01:37.130+0800 [conn1513] *** unhandled exception 0xC00000FD at 0x000000013FFDDF87, terminatingrn2015-11-30T11:01:37.130+0800 [conn1513] *** stack trace for unhandled exception:rn2015-11-30T11:01:37.176+0800 [initandlisten] can't create new thread, closing connectionrn2015-11-30T11:01:37.192+0800 [initandlisten] can't create new thread, closing connectionrn############## rn2015-11-30T11:01:40.562+0800 [initandlisten] can't create new thread, closing connectionrn############## rn2015-11-30T11:01:41.732+0800 [conn1486] mongod.exe ???rn2015-11-30T11:01:41.732+0800 [conn1486] mongod.exe ???rn2015-11-30T11:01:41.732+0800 [conn1486] mongod.exe ???rn2015-11-30T11:01:41.732+0800 [conn1486] mongod.exe ???rn2015-11-30T11:01:41.732+0800 [conn1486] mongod.exe ???rn2015-11-30T11:01:41.732+0800 [conn1486] ############## rn2015-11-30T11:01:41.732+0800 [conn1486] rnrn***aborting after fassert() failurernrnrn2015-11-30T11:01:43.588+0800 [conn1511] mongod.exe v8::internal::OS::Abort+0x22rn2015-11-30T11:01:43.588+0800 [conn1511] mongod.exe ???rn2015-11-30T11:01:43.588+0800 [conn1511] mongod.exe ???rn2015-11-30T11:01:43.588+0800 [conn1511] mongod.exe ???rn2015-11-30T11:01:43.588+0800 [conn1511] mongod.exe ???rn2015-11-30T11:01:43.588+0800 [conn1511] mongod.exe ???rn2015-11-30T11:01:43.588+0800 [conn1511] mongod.exe ???rn2015-11-30T11:01:43.588+0800 [conn1511] mongod.exe ???rn2015-11-30T11:01:43.588+0800 [conn1511] rn2015-11-30T11:01:43.697+0800 [conn1511] writing minidump diagnostic file C:\MongoDB\bin\mongod.2015-11-30T03-01-43.mdmprn2015-11-30T11:01:48.362+0800 [conn1511] *** immediate exit due to unhandled exceptionrn2015-11-30T11:09:41.837+0800 ***** SERVER RESTARTED *****rn2015-11-30T11:09:41.837+0800 Trying to start Windows service 'MongoDB'rn2015-11-30T11:09:41.837+0800 Service runningrn2015-11-30T11:09:41.837+0800 [initandlisten] MongoDB starting : pid=4496 port=27017 dbpath=C:\MongoDB\data 64-bit host=alris-002rn2015-11-30T11:09:41.837+0800 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2rn2015-11-30T11:09:41.837+0800 [initandlisten] db version v2.6.5rn2015-11-30T11:09:41.837+0800 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6rn2015-11-30T11:09:41.837+0800 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49rn2015-11-30T11:09:41.837+0800 [initandlisten] allocator: systemrn2015-11-30T11:09:41.837+0800 [initandlisten] options: security: authorization: "enabled" , service: true, storage: dbPath: "C:\MongoDB\data", directoryPerDB: true , systemLog: destination: "file", logAppend: true, path: "C:\MongoDB\log.txt", quiet: true rn2015-11-30T11:09:42.165+0800 [initandlisten] journal dir=C:\MongoDB\data\journalrn2015-11-30T11:09:42.165+0800 [initandlisten] recover beginrn2015-11-30T11:09:42.165+0800 [initandlisten] recover lsn: 133849289rn2015-11-30T11:09:42.165+0800 [initandlisten] recover C:\MongoDB\data\journal\j._2rn2015-11-30T11:09:42.321+0800 [initandlisten] recover skipping application of section seq:95422071 < lsn:133849289rn2015-11-30T11:09:42.648+0800 [initandlisten] recover skipping application of section seq:95460431 < lsn:133849289rn2015-11-30T11:09:43.304+0800 [initandlisten] recover skipping application of section seq:95498901 < lsn:133849289rn2015-11-30T11:09:43.896+0800 [initandlisten] recover skipping application of section seq:95537381 < lsn:133849289rn2015-11-30T11:09:44.552+0800 [initandlisten] recover skipping application of section seq:95575811 < lsn:133849289rn2015-11-30T11:09:45.207+0800 [initandlisten] recover skipping application of section seq:95614291 < lsn:133849289rn2015-11-30T11:09:46.096+0800 [initandlisten] recover skipping application of section seq:95652762 < lsn:133849289rn2015-11-30T11:09:46.626+0800 [initandlisten] recover skipping application of section seq:95691222 < lsn:133849289rn2015-11-30T11:09:47.141+0800 [initandlisten] recover skipping application of section seq:95729702 < lsn:133849289rn2015-11-30T11:09:47.859+0800 [initandlisten] recover skipping application of section more...rn2015-11-30T11:19:28.787+0800 CTRL_SHUTDOWN_EVENT signalrn2015-11-30T11:19:28.787+0800 [consoleTerminate] got CTRL_SHUTDOWN_EVENT, will terminate after current cmd endsrn2015-11-30T11:19:28.943+0800 [consoleTerminate] now exitingrn2015-11-30T11:19:28.943+0800 [initandlisten] dbexception during recovery: 11600 interrupted at shutdownrn2015-11-30T11:19:28.943+0800 [DataFileSync] flushing mmaps took 527093ms for 0 filesrn2015-11-30T11:19:28.943+0800 [consoleTerminate] dbexit: rn2015-11-30T11:19:28.943+0800 [consoleTerminate] shutdown: going to close listening sockets...rn2015-11-30T11:19:28.943+0800 [consoleTerminate] shutdown: going to flush diaglog...rn2015-11-30T11:19:28.943+0800 [consoleTerminate] shutdown: going to close sockets...rn2015-11-30T11:19:28.943+0800 [consoleTerminate] shutdown: waiting for fs preallocator...rn2015-11-30T11:19:28.943+0800 [consoleTerminate] shutdown: lock for final commit...rn2015-11-30T11:19:28.943+0800 [consoleTerminate] shutdown: final commit...rn2015-11-30T11:19:28.959+0800 [consoleTerminate] shutdown: closing all files...rn2015-11-30T11:19:28.959+0800 [consoleTerminate] closeAllFiles() finishedrn2015-11-30T11:19:28.959+0800 [consoleTerminate] shutdown: removing fs lock...rn2015-11-30T11:19:28.959+0800 [consoleTerminate] dbexit: really exiting nowrn2015-11-30T11:24:19.489+0800 ***** SERVER RESTARTED *****rn2015-11-30T11:24:20.721+0800 Trying to start Windows service 'MongoDB'rn2015-11-30T11:24:20.721+0800 Service runningrn2015-11-30T11:24:21.486+0800 [initandlisten] MongoDB starting : pid=1636 port=27017 dbpath=C:\MongoDB\data 64-bit host=alris-002rn2015-11-30T11:24:21.486+0800 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2rn2015-11-30T11:24:21.486+0800 [initandlisten] db version v2.6.5rn2015-11-30T11:24:21.486+0800 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6rn2015-11-30T11:24:21.486+0800 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49rn2015-11-30T11:24:21.486+0800 [initandlisten] allocator: systemrn2015-11-30T11:24:21.486+0800 [initandlisten] options: security: authorization: "enabled" , service: true, storage: dbPath: "C:\MongoDB\data", directoryPerDB: true , systemLog: destination: "file", logAppend: true, path: "C:\MongoDB\log.txt", quiet: true rn2015-11-30T11:24:22.219+0800 [initandlisten] journal dir=C:\MongoDB\data\journalrn2015-11-30T11:24:22.250+0800 [initandlisten] recover beginrn2015-11-30T11:24:22.390+0800 [initandlisten] recover lsn: 133849289rn2015-11-30T11:24:22.390+0800 [initandlisten] recover C:\MongoDB\data\journal\j._2rn2015-11-30T11:24:23.685+0800 [initandlisten] recover skipping application of section seq:95422071 < lsn:133849289rn2015-11-30T11:24:24.418+0800 [initandlisten] recover skipping application of section seq:95460431 < lsn:133849289rn2015-11-30T11:24:26.056+0800 [initandlisten] recover skipping application of section seq:95498901 < lsn:133849289rn2015-11-30T11:24:28.365+0800 [initandlisten] recover skipping application of section seq:95537381 < lsn:133849289rn2015-11-30T11:24:30.580+0800 [initandlisten] recover skipping application of section seq:95575811 < lsn:133849289rn2015-11-30T11:24:32.608+0800 [initandlisten] recover skipping application of section seq:95614291 < lsn:133849289rn2015-11-30T11:24:35.853+0800 [initandlisten] recover skipping application of section seq:95652762 < lsn:133849289rn2015-11-30T11:24:38.817+0800 [initandlisten] recover skipping application of section seq:95691222 < lsn:133849289rn2015-11-30T11:24:41.906+0800 [initandlisten] recover skipping application of section seq:95729702 < lsn:133849289rn2015-11-30T11:24:43.700+0800 [initandlisten] recover skipping application of section more...rn2015-11-30T11:40:26.994+0800 [serviceShutdown] got SERVICE_CONTROL_STOP request from Windows Service Control Manager, will terminate after current cmd endsrn2015-11-30T11:40:27.633+0800 [DataFileSync] flushing mmaps took 906836ms for 0 filesrn2015-11-30T11:40:27.633+0800 [serviceShutdown] now exitingrn2015-11-30T11:40:27.633+0800 [initandlisten] dbexception during recovery: 11600 interrupted at shutdownrn2015-11-30T11:40:27.633+0800 [serviceShutdown] dbexit: rn2015-11-30T11:40:27.633+0800 [serviceShutdown] shutdown: going to close listening sockets...rn2015-11-30T11:40:27.633+0800 [serviceShutdown] shutdown: going to flush diaglog...rn2015-11-30T11:40:27.633+0800 [serviceShutdown] shutdown: going to close sockets...rn2015-11-30T11:40:27.633+0800 [serviceShutdown] shutdown: waiting for fs preallocator...rn2015-11-30T11:40:27.633+0800 [serviceShutdown] shutdown: lock for final commit...rn2015-11-30T11:40:27.633+0800 [serviceShutdown] shutdown: final commit...rn2015-11-30T11:40:27.649+0800 [serviceShutdown] shutdown: closing all files...rn2015-11-30T11:40:27.649+0800 [serviceShutdown] closeAllFiles() finishedrn2015-11-30T11:40:27.649+0800 [serviceShutdown] shutdown: removing fs lock...rn
如何防止事件导致内存泄露
如何防止事件导致内存泄露 只是自己按照博客学习做的小DEMO
solr问题,大神帮忙看看
[img=https://img-bbs.csdn.net/upload/201405/07/1399431473_408783.jpg][/img]rnrn小弟第一次搞solr,这是启动时报的错误,大神帮忙看看是什么问题
关于android使用google地图问题。。。大神速来~
我在网上招了个例子,可是照搬以后调试不过。rn例子是关于google地图趋近提醒问题。rn代码如下:(要是觉得乱可以去博客看,往下找第五个就是[url=http://blog.csdn.net/wminxue319/article/details/7264777][/url])rnrnpackage com.android.map;rnrnimport android.app.Activity;rnimport android.app.PendingIntent;rnimport android.content.Context;rnimport android.content.Intent;rnimport android.location.LocationManager;rnimport android.os.Bundle;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.widget.Button;rnrnimport com.google.android.maps.MapActivity;rnimport com.google.android.maps.MapView;rnrnpublic class AndroidmapActivity extends Activity rn private static final String PROXIMITY_ALERT_ACTION_NAME = "mx.android.ch14.ProximityAlert"; rn private Button btn; rn @Override rn protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState); rn setContentView(R.layout.main); rn btn = (Button) findViewById(R.id.button01); rn btn.setOnClickListener(new OnClickListener() rn @Override rn public void onClick(View arg0) rn set(); rn rn ); rn rn //趋近提示方法 rn private void set() rn //定位i服务常量 rn String locService = Context.LOCATION_SERVICE; rn //定位i服务管理器实例 rn LocationManager locationManager; rnlocationManager = (LocationManager) getSystemService(locService); rn//声明经度 rndouble lat = 37.4; rn//声明纬度 rndouble lng = 55.0; rn//声明半径(单位米) rnfloat radius = 200f; rn//不过期 rnlong expiration = -1; rnIntent intent = new Intent(PROXIMITY_ALERT_ACTION_NAME); rn PendingIntent pi = PendingIntent.getBroadcast(this, -1, intent, 0); rn//添加趋近警告 rnlocationManager.addProximityAlert(lat, lng, radius, expiration, pi); rn rnrnrnrn第二个类rnpackage com.android.map;rnrnimport android.content.BroadcastReceiver;rnimport android.content.Context;rnimport android.content.Intent;rnimport android.location.LocationManager;rnimport android.widget.Toast;rnrnpublic class ProximityAlertReciever extends BroadcastReceiver rn @Override rn public void onReceive(Context context, Intent intent) rn //趋近关键字 rn String key = LocationManager.KEY_PROXIMITY_ENTERING; rn //从Intent获得额外信息,判断是否进入设置区域 rn boolean isEnter = intent.getBooleanExtra(key, false); rn if(isEnter) rn Toast.makeText(context, "你已经进入海淀区!", Toast.LENGTH_LONG).show(); rn rn rnrnrnmain.xmlrnrnrnrnrnrnrn rnrnrnrnandroidMainifest.xmlrnrnrnrn rn rn rn rn rn rn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rnrnrnrnrn我的做法就是新建了个android类把这些贴进去,修改类名。rnrn错误提示:rn运行程序后先提示了一个错误。rnerror opening trace file: No such file or directory (2)rnrn 然后在模拟器中点击了按钮后就会提示一堆错误。rn08-22 15:15:13.424: E/AndroidRuntime(1206): FATAL EXCEPTION: mainrn08-22 15:15:13.424: E/AndroidRuntime(1206): java.lang.SecurityException: Requires ACCESS_FINE_LOCATION permissionrn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.os.Parcel.readException(Parcel.java:1425)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.os.Parcel.readException(Parcel.java:1379)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.location.ILocationManager$Stub$Proxy.addProximityAlert(ILocationManager.java:818)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.location.LocationManager.addProximityAlert(LocationManager.java:1089)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at com.android.map.AndroidmapActivity.set(AndroidmapActivity.java:49)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at com.android.map.AndroidmapActivity.access$0(AndroidmapActivity.java:32)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at com.android.map.AndroidmapActivity$1.onClick(AndroidmapActivity.java:27)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.view.View.performClick(View.java:4084)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.view.View$PerformClick.run(View.java:16966)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.os.Handler.handleCallback(Handler.java:615)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.os.Handler.dispatchMessage(Handler.java:92)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.os.Looper.loop(Looper.java:137)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at android.app.ActivityThread.main(ActivityThread.java:4745)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at java.lang.reflect.Method.invokeNative(Native Method)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at java.lang.reflect.Method.invoke(Method.java:511)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)rn08-22 15:15:13.424: E/AndroidRuntime(1206): at dalvik.system.NativeStart.main(Native Method)rnrn怎么解决?另外,趋近提醒还有别的实现方法吗?rnrn
求大神帮忙看看小程序,不知道问题出在哪?
.386rn.model flat, stdcallrnincludelib msvcrt.librnprintf PROTO C :ptr sbytef,:varargrnscanf PROTO C : ptr sbyte,:varargrn.data rn year1 dword ?rn month1 dword ?rn day1 dword ?rn year2 dword ?rn month2 dword ?rn day2 dword ?rn N = 2 rn szouputFmt1 byte 'the first date is %d/%d/%d',0ah,0rn szouputFmt2 byte 'the second date is %d/%d/%d',0ah,0rn szouputFmt byte 'the bigger date is %d/%d/%d',0ah,0rn szouputFme byte 'equal!',0ah,0rn szinputFmt byte '%d%d%d',0ah,0rn.codernstart:rn mov esi Nrn invoke scanf,offset szinputFmt,offset year1,offset month1,offset day1rn invoke printf,offset szouputfmt1,year1,month1,day1rn sub esi 1rn invoke scanf,offset szinputFmt,offset year2,offset month2,offset day2rn invoke printf,offset szouputfmt2,year2,month2,day2rn sub esi 1rn jz c10rnc10:rn mov eax year1rn sub eax year2rn jz c20rn jb c30rn ja c40rnc30:rn invoke printf offset szouputFmt year2,month2,day2rnc40:rn invoke printf offset szouputFmt year1,month2,day2 rn rnc20:rn mov eax month1rn sub eax month2rn jz c50rn jb c60rn ja c70rnc60:rn invoke printf offset szouputFmt year2,month2,day2rnc70:rn invoke printf offset szouputFmt year1,month2,day2 rnc50:rn mov eax day1rn sub eax day2rn jz c80rn jb c90rn ja c100rn rnc90:rn invoke printf offset szouputFmt year2,month2,day2rnc100:rn invoke printf offset szouputFmt year1,month2,day2 rnc80:rn invoke printf offset szouputFmern retrnend start rnrn 这是一个简单的比较日期的程序,连接时总是报错,希望大神帮忙! rn rn rn rn
请高人帮忙看看内存泄露问题
调试过程中,出现下面信息:rnrnstrcore.cpp(118) : 258 normal block at 0x00B35570, 269 bytes long.rn Data: < 0.6 > FF FF FF FF 03 00 00 00 00 01 00 00 30 2E 36 00 rnstrcore.cpp(118) : 257 normal block at 0x00B356B0, 269 bytes long.rn Data: < 0.6 > FF FF FF FF 03 00 00 00 00 01 00 00 30 2E 36 00 rnstrcore.cpp(118) : 256 normal block at 0x00B357F0, 269 bytes long.rn Data: < 21.1> FF FF FF FF 04 00 00 00 00 01 00 00 32 31 2E 31 rnplex.cpp(31) : 255 normal block at 0x00B35930, 124 bytes long.rn Data: < x7D > 00 00 00 00 00 00 00 00 78 37 44 00 01 00 00 00 rnmap_pp.cpp(72) : 254 normal block at 0x00B34170, 68 bytes long.rn Data: < @Y > 00 00 00 00 00 00 00 00 00 00 00 00 40 59 B3 00 rnstrcore.cpp(118) : 253 normal block at 0x00B359E0, 269 bytes long.rn Data: < 07/3> FF FF FF FF 11 00 00 00 00 01 00 00 30 37 2F 33 rnstrcore.cpp(118) : 246 normal block at 0x00B341E0, 26 bytes long.rn Data: < [YJG> 01 00 00 00 0D 00 00 00 0D 00 00 00 5B 59 4A 47 rnstrcore.cpp(118) : 237 normal block at 0x00B340A0, 67 bytes long.rn Data: < 6 6 SELE> 01 00 00 00 36 00 00 00 36 00 00 00 53 45 4C 45 rnstrcore.cpp(118) : 222 normal block at 0x00B342E0, 132 bytes long.rn Data: < w w ODBC> 01 00 00 00 77 00 00 00 77 00 00 00 4F 44 42 43 rndbcore.cpp(2283) : 217 client block at 0x00B34480, subtype 0, 100 bytes long.rna CDatabase object at $00B34480, 100 bytes longrnstrcore.cpp(118) : 212 normal block at 0x00B34570, 269 bytes long.rn Data: < 0.6 > FF FF FF FF 03 00 00 00 00 01 00 00 30 2E 36 00 rnstrcore.cpp(118) : 211 normal block at 0x00B346B0, 269 bytes long.rn Data: < 0.6 > FF FF FF FF 03 00 00 00 00 01 00 00 30 2E 36 00 rnstrcore.cpp(118) : 210 normal block at 0x00B347F0, 269 bytes long.rn Data: < 20.5> FF FF FF FF 04 00 00 00 00 01 00 00 32 30 2E 35 rnplex.cpp(31) : 209 normal block at 0x00B34930, 124 bytes long.rn Data: < 8D > 00 00 00 00 00 00 00 00 98 38 44 00 01 00 00 00 rnmap_pp.cpp(72) : 208 normal block at 0x00B33170, 68 bytes long.rn Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 rnstrcore.cpp(118) : 207 normal block at 0x00B349E0, 269 bytes long.rn Data: < 07/3> FF FF FF FF 11 00 00 00 00 01 00 00 30 37 2F 33 rnstrcore.cpp(118) : 200 normal block at 0x00B331E0, 26 bytes long.rn Data: < [YJG> 01 00 00 00 0D 00 00 00 0D 00 00 00 5B 59 4A 47 rnstrcore.cpp(118) : 191 normal block at 0x00B330A0, 67 bytes long.rn Data: < 6 6 SELE> 01 00 00 00 36 00 00 00 36 00 00 00 53 45 4C 45 rnstrcore.cpp(118) : 176 normal block at 0x00B332E0, 132 bytes long.rn Data: < w w ODBC> 01 00 00 00 77 00 00 00 77 00 00 00 4F 44 42 43 rndbcore.cpp(2283) : 171 client block at 0x00B33480, subtype 0, 100 bytes long.rna CDatabase object at $00B33480, 100 bytes longrnstrcore.cpp(118) : 166 normal block at 0x00B33570, 269 bytes long.rn Data: < 3.6 > FF FF FF FF 03 00 00 00 00 01 00 00 33 2E 36 00 rnstrcore.cpp(118) : 165 normal block at 0x00B336B0, 269 bytes long.rn Data: < 3.4 > FF FF FF FF 03 00 00 00 00 01 00 00 33 2E 34 00 rnstrcore.cpp(118) : 164 normal block at 0x00B337F0, 269 bytes long.rn Data: < 22.5> FF FF FF FF 04 00 00 00 00 01 00 00 32 32 2E 35 rnplex.cpp(31) : 163 normal block at 0x00B33930, 124 bytes long.rn Data: < 9D > 00 00 00 00 00 00 00 00 B8 39 44 00 01 00 00 00 rnmap_pp.cpp(72) : 162 normal block at 0x00B32170, 68 bytes long.rn Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 rnstrcore.cpp(118) : 161 normal block at 0x00B339E0, 269 bytes long.rn Data: < 07/3> FF FF FF FF 11 00 00 00 00 01 00 00 30 37 2F 33 rnstrcore.cpp(118) : 154 normal block at 0x00B321E0, 26 bytes long.rn Data: < [YJG> 01 00 00 00 0D 00 00 00 0D 00 00 00 5B 59 4A 47 rnstrcore.cpp(118) : 145 normal block at 0x00B320A0, 67 bytes long.rn Data: < 6 6 SELE> 01 00 00 00 36 00 00 00 36 00 00 00 53 45 4C 45 rnstrcore.cpp(118) : 130 normal block at 0x00B322E0, 132 bytes long.rn Data: < w w ODBC> 01 00 00 00 77 00 00 00 77 00 00 00 4F 44 42 43 rndbcore.cpp(2283) : 125 client block at 0x00B32480, subtype 0, 100 bytes long.rna CDatabase object at $00B32480, 100 bytes longrnObject dump complete.rnThe thread 0x7FC has exited with code 3 (0x3).rnrn请高人分析一下会是什么问题啊?
关于内存泄露的问题,高手帮忙看看!
在进行程序设计的过程中,内存泄露是经常存在的,怎样判断程序没有内存泄露呢?rn当调试运行程序时,在关闭程序时,如果有泄露,下方会提示泄露信息。rn我安装了一个叫BoundsCheak也可以检查内存泄露,到底是VC提示的内存泄露准呢?还是BoundsCheak给出的内存泄露准呢?rn我的这个程序,当我不用BoundsCheak时,没有内存泄露,当用BoundsCheak进行调试运行时,内存泄露不计其数:rnint __cdecl __sbh_heap_init (void)rnrn if (!(__sbh_pHeaderList = HeapAlloc(_crtheap, 0, 16 * sizeof(HEADER))))rn return FALSE;rnrn __sbh_pHeaderScan = __sbh_pHeaderList;rn __sbh_pHeaderDefer = NULL;rn __sbh_cntHeaderList = 0;rn __sbh_sizeHeaderList = 16;rnrn return TRUE;rnrnrnif ( (__piob = (void **)_calloc_crt( _nstream, sizeof(void *) )) ==rn NULL )//有多次都是这个函数泄露,而且泄露很多.rn请大家帮忙分析下!
请大家帮忙看看内存泄露问题
请大家帮忙看看这个程序哪里会产生内存泄露rn代码是直接可以运行的,粘贴就好rn[code=C/C++]rn/* This is the Porter stemming algorithm, coded up in ANSI C by thernauthor. It may be be regarded as cononical, in that it follows thernalgorithm presented inrnrnPorter, 1980, An algorithm for suffix stripping, Program, Vol. 14,rnno. 3, pp 130-137,rnrnonly differing from it at the points maked --DEPARTURE-- below.rnrnSee also http://www.tartarus.org/~martin/PorterStemmerrnrnThe algorithm as described in the paper could be exactly replicatedrnby adjusting the points of DEPARTURE, but this is barely necessary,rnbecause (a) the points of DEPARTURE are definitely improvements, andrn(b) no encoding of the Porter stemmer I have seen is anything likernas exact as this version, even with the points of DEPARTURE!rnrnYou can compile it on Unix with 'gcc -O3 -o stem stem.c' after whichrn'stem' takes a list of inputs and sends the stemmed equivalent tornstdout.rnrnThe algorithm as encoded here is particularly fast.rnrnRelease 1rn*/rnrn#include /* for memmove */rn//#include rn#include rn#ifndef TRUErn#define TRUE truern#endifrn#ifndef FALSErn#define FALSE falsern#endifrnrnrnrn/* The main part of the stemming algorithm starts here. b is a bufferrnholding a word to be stemmed. The letters are in b[k0], b[k0+1] ...rnending at b[k]. In fact k0 = 0 in this demo program. k is readjustedrndownwards as the stemming progresses. Zero termination is not in factrnused in the algorithm.rnrnNote that only lower case sequences are stemmed. Forcing to lower casernshould be done before stem(...) is called.rn*/rnrnstatic char * b; /* buffer for word to be stemmed */rnstatic int k,k0,j; /* j is a general offset into the string */rnrn/* cons(i) is TRUE <=> b[i] is a consonant. */rnrnstatic int cons(int i)rn switch (b[i])rn case 'a': case 'e': case 'i': case 'o': case 'u': return FALSE;rn case 'y': return (i==k0) ? TRUE : !cons(i-1);rn default: return TRUE;rnrnrnrn/* m() measures the number of consonant sequences between k0 and j. if c isrna consonant sequence and v a vowel sequence, and <..> indicates arbitraryrnpresence,rnrn gives 0rnvc gives 1rnvcvc gives 2rnvcvcvc gives 3rn....rn*/rnrnstatic int m()rn int n = 0;rnint i = k0;rnwhile(TRUE)rn if (i > j) return n;rnif (! cons(i)) break; i++;rnrni++;rnwhile(TRUE)rn while(TRUE)rn if (i > j) return n;rnif (cons(i)) break;rni++;rnrni++;rnn++;rnwhile(TRUE)rn if (i > j) return n;rnif (! cons(i)) break;rni++;rnrni++;rnrnrnrn/* vowelinstem() is TRUE <=> k0,...j contains a vowel */rnrnstatic int vowelinstem()rn int i; for (i = k0; i <= j; i++) if (! cons(i)) return TRUE;rnreturn FALSE;rnrnrn/* doublec(j) is TRUE <=> j,(j-1) contain a double consonant. */rnrnstatic int doublec(int j)rn if (j < k0+1) return FALSE;rnif (b[j] != b[j-1]) return FALSE;rnreturn cons(j);rnrnrn/* cvc(i) is TRUE <=> i-2,i-1,i has the form consonant - vowel - consonantrnand also if the second c is not w,x or y. this is used when trying tornrestore an e at the end of a short word. e.g.rnrncav(e), lov(e), hop(e), crim(e), butrnsnow, box, tray.rnrn*/rnrnstatic int cvc(int i)rn if (i < k0+2 || !cons(i) || cons(i-1) || !cons(i-2)) return FALSE;rn int ch = b[i];rnif (ch == 'w' || ch == 'x' || ch == 'y') return FALSE;rnrnreturn TRUE;rnrnrn/* ends(s) is TRUE <=> k0,...k ends with the string s. */rnrnstatic int ends(char * s)rn int length = s[0];rnif (s[length] != b[k]) return FALSE; /* tiny speed-up */rnif (length > k-k0+1) return FALSE;rnif (memcmp(b+k-length+1,s+1,length) != 0) return FALSE;rnj = k-length;rnreturn TRUE;rnrnrn/* setto(s) sets (j+1),...k to the characters in the string s, readjustingrnk. */rnrnstatic void setto(char * s)rn int length = s[0];rnmemmove(b+j+1,s+1,length);rnk = j+length;rnrnrn/* r(s) is used further down. */rnrnstatic void r(char * s) if (m() > 0) setto(s); rnrn/* step1ab() gets rid of plurals and -ed or -ing. e.g.rnrncaresses -> caressrnponies -> ponirnties -> tirncaress -> caressrncats -> catrnrnfeed -> feedrnagreed -> agreerndisabled -> disablernrnmatting -> matrnmating -> maternmeeting -> meetrnmilling -> millrnmessing -> messrnrnmeetings -> meetrnrn*/rnrnstatic void step1ab()rn if (b[k] == 's')rn if (ends("\04" "sses")) k -= 2; elsernif (ends("\03" "ies")) setto("\01" "i"); elsernif (b[k-1] != 's') k--;rnrnif (ends("\03" "eed")) if (m() > 0) k--; elsernif ((ends("\02" "ed") || ends("\03" "ing")) && vowelinstem())rn k = j;rnif (ends("\02" "at")) setto("\03" "ate"); elsernif (ends("\02" "bl")) setto("\03" "ble"); elsernif (ends("\02" "iz")) setto("\03" "ize"); elsernif (doublec(k))rn k--;rn int ch = b[k];rnif (ch == 'l' || ch == 's' || ch == 'z') k++;rnrnrnelse if (m() == 1 && cvc(k)) setto("\01" "e");rnrnrnrn/* step1c() turns terminal y to i when there is another vowel in the stem. */rnrnstatic void step1c() if (ends("\01" "y") && vowelinstem()) b[k] = 'i'; rnrnrn/* step2() maps double suffices to single ones. so -ization ( = -ize plusrn-ation) maps to -ize etc. note that the string before the suffix must givernm() > 0. */rnrnstatic void step2() switch (b[k-1])rnrn case 'a': if (ends("\07" "ational")) r("\03" "ate"); break; rn if (ends("\06" "tional")) r("\04" "tion"); break; rn break;rn case 'c': if (ends("\04" "enci")) r("\04" "ence"); break; rn if (ends("\04" "anci")) r("\04" "ance"); break; rn break;rn case 'e': if (ends("\04" "izer")) r("\03" "ize"); break; rn break;rn case 'l': if (ends("\03" "bli")) r("\03" "ble"); break; /*-DEPARTURE-*/rnrn /* To match the published algorithm, replace this line withrn case 'l': if (ends("\04" "abli")) r("\04" "able"); break; */rnrn if (ends("\04" "alli")) r("\02" "al"); break; rn if (ends("\05" "entli")) r("\03" "ent"); break; rn if (ends("\03" "eli")) r("\01" "e"); break; rn if (ends("\05" "ousli")) r("\03" "ous"); break; rn break;rn case 'o': if (ends("\07" "ization")) r("\03" "ize"); break; rn if (ends("\05" "ation")) r("\03" "ate"); break; rn if (ends("\04" "ator")) r("\03" "ate"); break; rn break;rn case 's': if (ends("\05" "alism")) r("\02" "al"); break; rn if (ends("\07" "iveness")) r("\03" "ive"); break; rn if (ends("\07" "fulness")) r("\03" "ful"); break; rn if (ends("\07" "ousness")) r("\03" "ous"); break; rn break;rn case 't': if (ends("\05" "aliti")) r("\02" "al"); break; rn if (ends("\05" "iviti")) r("\03" "ive"); break; rn if (ends("\06" "biliti")) r("\03" "ble"); break; rn break;rn case 'g': if (ends("\04" "logi")) r("\03" "log"); break; /*-DEPARTURE-*/rnrn /* To match the published algorithm, delete this line */rnrn rnrn/* step3() deals with -ic-, -full, -ness etc. similar strategy to step2. */rnrnstatic void step3() switch (b[k])rnrn case 'e': if (ends("\05" "icate")) r("\02" "ic"); break; rn if (ends("\05" "ative")) r("\00" ""); break; rn if (ends("\05" "alize")) r("\02" "al"); break; rn break;rn case 'i': if (ends("\05" "iciti")) r("\02" "ic"); break; rn break;rn case 'l': if (ends("\04" "ical")) r("\02" "ic"); break; rn if (ends("\03" "ful")) r("\00" ""); break; rn break;rn case 's': if (ends("\04" "ness")) r("\00" ""); break; rn break;rn rnrnrnrnrn[/code]
关于Android VideoView导致的内存泄漏的问题
今天用 leakcanary 时发现用VideoView的 activity 出现泄漏,捕获到如下的信息,简单说就是 android M(6.0)以前AudioManager用的Context是 当前传入的,当activity finish之后 AudioManager依然保持对它的引用,所以就leak了,6.0后改用ApplicationContext修复了此问题,google后发现下面这种解决
CDC导致的内存泄露问题总结
对于不停的获得和释放绘图设备句柄(DC)可能会导致GDI内存泄露。本文总结出以下几条经验防止内存泄露。
关于android socket通讯,求大神帮看看
写了个android与pc端通信的例子,pc端用的是mfc写的,做服务端。想实现以下功能:rnandroid填写完用户名和密码点击登录按钮,android把用户名和密码打包发给pc端,pc端收到后在发出一条消息给android,android收到并解析这条消息后启动一个新Activity。rn现在的情况是android能给PC发信息,PC端给android发信息收不到。rn这是android的源码:rnpackage com.example.sendtoserver;rnrnimport java.io.BufferedReader;rnimport java.io.BufferedWriter;rnimport java.io.IOException;rnimport java.io.InputStreamReader;rnimport java.io.OutputStreamWriter;rnimport java.net.Socket;rnimport java.net.UnknownHostException;rnrnrnimport android.os.Bundle;rnimport android.os.Message;rnimport android.os.StrictMode;rnimport android.app.Activity;rnimport android.content.Intent;rnimport android.util.Log;rnimport android.view.Menu;rnimport android.view.View;rnimport android.view.View.OnClickListener;rnimport android.widget.Button;rnimport android.widget.EditText;rnrnpublic class MainActivity extends Activityrnrn Socket socket=null;rn String ip="192.168.137.1";rn int port=8888;rn BufferedReader br=null;rn BufferedWriter bw=null;rn Button loginButton=null;rn EditText username=null;rn EditText password=null;rn ReceiveThread receThread=null;rn String receString=null;rn InitThread it=null;rn @Overridern protected void onCreate(Bundle savedInstanceState)rn rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity_main);rn setContentView(R.layout.activity_main);rn rn loginButton=(Button)this.findViewById(R.id.login);rn loginButton.setOnClickListener(new OnClickListener() rn rn @Overridern public void onClick(View arg0) rn rn // TODO Auto-generated method stubrn if(bw!=null)rn rn tryrn rn bw.write("/Cmd Login /username "+username.getText().toString()+" /password "+password.getText().toString()+" /");rn bw.flush();rn rn catch (IOException e)rn rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn rn );rn username=(EditText)this.findViewById(R.id.username);rn password=(EditText)this.findViewById(R.id.password);rn rn it=new InitThread();rn it.start();rn receThread=new ReceiveThread();rn receThread.start();rn rn class InitThread extends Threadrn rnrn @Overridern public void run() rn rn // TODO Auto-generated method stubrn super.run();rn tryrn rn socket=new Socket(ip,port);rn bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));rn br=new BufferedReader(new InputStreamReader(socket.getInputStream()));rn rn catch (UnknownHostException e)rn rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn catch (IOException e)rn rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn rn rn class ReceiveThread extends Threadrn rnrn @Overridern public void run()rn rn // TODO Auto-generated method stubrn super.run();rn if(br!=null)rn rn try rn rn int count=0;rn char[] buffer=null;rn while(true)rn rn if((count=br.read(buffer))>0)rn rn break;rn rn rn receString=buffer.toString();rn String[] cmd=parse(receString);rn Intent intent=new Intent();rn intent.putExtra("id",(cmd[2].split(" "))[1]);rn intent.putExtra("queueId",(cmd[3].split(" "))[1]);rn intent.putExtra("queueName",(cmd[4].split(" "))[1]);rn intent.setClass(MainActivity.this,ListActivity.class);rn (MainActivity.this).startActivity(intent);rn rn catch (IOException e) rn rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn rn private String[] parse(String rece)rn rn String[] elem=null;rn elem=rece.split("/");rn return elem;rn rn rn @Overridern public boolean onCreateOptionsMenu(Menu menu)rn rn // Inflate the menu; this adds items to the action bar if it is present.rn getMenuInflater().inflate(R.menu.main, menu);rn return true;rn rn @Overridern protected void onDestroy()rn rn // TODO Auto-generated method stubrn super.onDestroy();rn if(socket!=null)rn rn tryrn rn socket.close();rn rn catch (IOException e)rn rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn if(br!=null)rn rn try rn rn br.close();rn rn catch (IOException e) rn rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn if(bw!=null)rn rn try rn rn bw.close();rn rn catch (IOException e) rn rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn// it.destroy();rn// receThread.destroy();rn rn rn rn
Android开发编码规范导致的内存泄露问题
在很久很久之前,看过一篇关于内存泄露的文章,里面列举了比较全的应该注意的问题,后来找不到原文地址,今天翻了微博,找到了该文章,为了方便日后自己查看,将注意的问题提取出来。在android开发中,我们的编码习惯可能会让我们编写出一些容易导致内存泄露的代码。所以我们应该要养成一个良好的编码习惯。
操作系统不同导致的内存泄露问题!
做了一个程序,在win2000与winxp下运行没有问题!从任务管理器里面也看不到内存的泄露。rn但是在win98下,程序的界面被反复遮挡后造成界面无法刷新,然后所有的系统窗口变大!怀疑是内存泄露!rn各位大大能知道是什么原因造成的吗?rn如果有哪些api在win98下操正内存泄露也告诉一下吧!rn谢谢!!!rn(分分分肯定送上!)
来大神帮忙看看
消息 4511,级别 16,状态 1,过程 HOSP_MEDICATION_INFO,第 4 行rn创建视图或函数失败,因为没有为第 26 列指定列名。rnrn我对SQL Server不懂。rn创建视图出这个异常,单查询的话有数据。
求大神帮忙 看看!!
Fatal error: Call to a member function recordcount() on a non-object in C:\Users\Administrator\Desktop\oecsm\Apache2\htdocs\classes\user.class.php on line 34rnrnrn项目更改数据库之后就报这个错!
各路大神帮忙看看
这是我写的一段代码,但是输出的东西很怪异。rn[code=C/C++][/code]#includernusing namespace std;rnrnvoid print(int *a,int d)rn rn for(int i=0;i>n;rn a=new int[n];rn rn rn cout<<"请依次输入数组中的元素:"<>*a;rn a++;rn rn print(a,n);rn delete[] a;rn system("pause");rnrnrn大家帮忙修改一下,最好在错误的地方帮忙注释一下,谢谢了。
求大神帮忙,!看看
/* 题目:一球从100米高度自由落下,rn * 每次落地后反跳回原高度的一半;rn * 再落下,求它在 第N次落地时,共经过多少米?rn * 第N次反弹多高?(将处理写到方法中,rn * 并且方法需要带一个参数,该参数表示第N次落地)rn */import java.util.Scanner;rnpublic class Test3 rnrn rn public static double method(int k)rn rn double sum=100;rn double h=100;rn for(int i=1;i<=k;i++)rn rn sum+=h/2*2;rn h=h/2;rn rn return sum;rn rn rn rnrn public static void main(String[] args)rn rn Scanner scanner=new Scanner(System.in);rn System.out.println("请输入第N次数:");rn int n=scanner.nextInt();rn double y=method(n);rn System.out.println(y);rnrn rn rn rn rn rn rnrn我的方案不行!求大神帮忙!rn
请大神帮忙看看
有一张纸,需要切割二半,纸放在平台上的位置不一样(有时纸歪了一点),但每次都要从纸的中心点切,先用相机拍摄纸的轮郭,然后在得到一个中心线,以及它的长度,rn然后用工控机来调用这个OPENCV里的DLL,来控制步进带动刀片去切割。rnrn用OPENCV怎么计算这个纸的中心线,以及它要切割的长度呢?一定要标定么?rn用距离变换可以吗?rn
求大神帮忙看看
public static void main(String[] args)rn System.out.println(getFormatNum("0.000",1.2224));rn System.out.println(getFormatNum("0.000",1.2225));rn System.out.println(getFormatNum("0.000",1.2226));rn System.out.println(getFormatNum("0.000",0.2224));rn System.out.println(getFormatNum("0.000",0.2225));rn System.out.println(getFormatNum("0.000",0.2226));rn System.out.println(getFormatNum("0.000",2.4924));rn System.out.println(getFormatNum("0.000",2.4925));rn System.out.println(getFormatNum("0.000",2.4926));rn rn rn public static Double getFormatNum(String pattren,Double data)rn String reStr = "";rn reStr = new java.text.DecimalFormat(pattren).format(data); rn return Double.parseDouble(reStr);rn rn为什么执行结果会是rn1.222rn1.222rn1.223rn0.222rn0.223rn0.223rn2.492rn2.493rn2.493rn当个位为1时并没有按照四舍五入的规则执行
大神帮忙看看
rn Assembly asm = Assembly.LoadFrom(Config.DEFAULT_MODEL_LIB_PATH); rn [color=#FF0000] List types = asm.GetTypes()rn .Where(type => type.GetInterfaces().Any(i => i.Name == "IModel")rn && type.IsClassrn && type.IsVisiblern && !type.IsAbstractrn && !type.IsNotPublic).ToList();[/color]rnrnrn红色块的写法是什么意思?求详解
各位大神帮忙看看!!!
前面定义了这个加密方法rn int AES_Encrypt(char *plainFile, char *keyStr,int keylength,char *cipherFile){}rnrnrn后面写的主函数 rn int main()rn rn AES_Encrypt("1.bmp","abcdefgabcdefg0123456789",24,"2.bmp");rn rnrn现在我想把主函数里的 1.bmp 改成由外界输入 怎么改啊 rn试了好多 都不行啊
各位大神帮忙看看。。。。
[code=delphi]rnprocedure TMainForm.RadioButton1Click(Sender: TObject);rnbeginrn Series1.Active:= true;rn CheckBox2.Checked:= true;rnend;rnrnprocedure TMainForm.CheckBox2Click(Sender: TObject);rnbeginrn if CheckBox2.Checked then Series1.Active:= truern else Series1.Active:= false;rn gbCurvePause:= true;rnend;rn[/code]rnrn各位大神帮我看看,实际我在程序界面在点击RadioButton的时候gbCurvePause标志也变为TRUE了。 rn可程序中只有点击CheckBox的是偶才会改变gbCurvePause啊啊啊啊 。。。
内存溢出了,大神帮忙看看
[img=https://img-bbs.csdn.net/upload/201506/18/1434621943_306917.png][/img]rn[img=https://img-bbs.csdn.net/upload/201506/18/1434621958_856320.png][/img]rn[img=https://img-bbs.csdn.net/upload/201506/18/1434621969_794550.png][/img]rn[img=https://img-bbs.csdn.net/upload/201506/18/1434621981_568782.png][/img]
求大神帮忙看看~
";rn $datanum = mysqli_num_rows($result);rn echo "共有".$totalnum."条留言,每页".$pagesize."条,共".$totalpage."页。 ";rn for( $i = 1; $i <= $totalpage; $i++)rn echo "[".$i."] ";rn rn echo " ";rn 43 $query = "select * from message order by addtime desc limit $begin,$pagesize";rn 44 $result = mysqli_query($link,$query);rn 45 $datanum = mysqli_num_rows($result);rn for( $i = 1; $i <= $datanum; $i++)//$datanum???rn $info = mysqli_fetch_array($result);rn echo " ".$row['author']."rn ".$row['addtime']."rn ".$row['content']."";rn rn mysqli_close($link)rn ?>rnrnrnrnrnrnrnrnwamp报错:Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\wamp64\www\message\ceshi1.php on line 45rnrn $datanum = mysqli_num_rows($result);也就是这一行错误,跪求~
大神帮忙看看什么问题
[code=c]#includern//using namespace std;rnrnvoid square(int&,int&);rnvoid cube(int&,int&);rnvoid swap(int&,int&);rnvoid getVals(int&,int&);rnvoid printVals(int,int);rnrnint main()rnrnrn int valOne=1 ,valTwo=2;rn int choice,i;rn const int maxArray=5;rnrn void(*pFuncArray[maxArray])(int&,int&);rnrnrn for(i=0;i>choice;rn switch(choice)rn rnrn case 1:rn pFuncArray[i]=getVals;rn break;rnrn case 2:rn pFuncArray[i]=square;rn break;rnrn case 3:rn pFuncArray[i]=cube;rn break;rnrn case 4:rnrn pFuncArray[i]=swap;rnrn default:rn pFuncArray[i]=0;rnrn rn rnrn for(i=0;i>rValone;rn std::cout<<"BBBBBBBBBBBBB:";rn std::cin>>rValTwo;rn[/code]rn[color=#FF0000]rn[size=24px]输入 1 2 3 4 2 2 3 , 他没办法识别 pFuncArray[i]=swap; 可能水平不够真的检测不到什么原因[/color][/size]
相关热词 c#检测非法字符 c#双屏截图 c#中怎么关闭线程 c# 显示服务器上的图片 api嵌入窗口 c# c# 控制网页 c# encrypt c#微信网页版登录 c# login 居中 c# 考试软件