Java 对象内存占用计算工具 jdk17

内存大小计算,在jdk<=8的版本中,可以使用ObjectSizeCalculator,这个类在8之后的版本被移出了。

还可以使用lucene-core的RamUsageEstimator来实现,但这个包中其他类都用不上,会增加最终包大小大约5M,为了减少包尺寸,就把这个类单独复制了一份出来,并做出一些适配修改:

1 移除了lucene中特定的类

2 移除了安全管理器的特权访问操作(jdk8之后不推荐使用安全管理器并标记为移除)

import lombok.extern.slf4j.Slf4j;import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.function.Function;
import java.util.logging.Logger;/*** Estimates the size (memory representation) of Java objects.** <p>This class uses assumptions that were discovered for the Hotspot virtual machine. If you use a* non-OpenJDK/Oracle-based JVM, the measurements may be slightly wrong.** @lucene.internal* @see #shallowSizeOf(Object)* @see #shallowSizeOfInstance(Class)*//*** @author heasy* @date 2024/7/11 下午3:14**/
@Slf4j
public final class RamUsageUtil {/*** One kilobyte bytes.*/public static final long ONE_KB = 1024;/*** One megabyte bytes.*/public static final long ONE_MB = ONE_KB * ONE_KB;/*** One gigabyte bytes.*/public static final long ONE_GB = ONE_KB * ONE_MB;/*** No instantiation.*/private RamUsageUtil() {}/*** True, iff compressed references (oops) are enabled by this JVM*/public static final boolean COMPRESSED_REFS_ENABLED;/*** Number of bytes this JVM uses to represent an object reference.*/public static final int NUM_BYTES_OBJECT_REF;/*** Number of bytes to represent an object header (no fields, no alignments).*/public static final int NUM_BYTES_OBJECT_HEADER;/*** Number of bytes to represent an array header (no content, but with alignments).*/public static final int NUM_BYTES_ARRAY_HEADER;/*** A constant specifying the object alignment boundary inside the JVM. Objects will always take a* full multiple of this constant, possibly wasting some space.*/public static final int NUM_BYTES_OBJECT_ALIGNMENT;/*** Approximate memory usage that we assign to all unknown queries - this maps roughly to a* BooleanQuery with a couple term clauses.*/public static final int QUERY_DEFAULT_RAM_BYTES_USED = 1024;/*** Approximate memory usage that we assign to all unknown objects - this maps roughly to a few* primitive fields and a couple short String-s.*/public static final int UNKNOWN_DEFAULT_RAM_BYTES_USED = 256;/*** Sizes of primitive classes.*/public static final Map<Class<?>, Integer> primitiveSizes;static {Map<Class<?>, Integer> primitiveSizesMap = new IdentityHashMap<>();primitiveSizesMap.put(boolean.class, 1);primitiveSizesMap.put(byte.class, 1);primitiveSizesMap.put(char.class, Integer.valueOf(Character.BYTES));primitiveSizesMap.put(short.class, Integer.valueOf(Short.BYTES));primitiveSizesMap.put(int.class, Integer.valueOf(Integer.BYTES));primitiveSizesMap.put(float.class, Integer.valueOf(Float.BYTES));primitiveSizesMap.put(double.class, Integer.valueOf(Double.BYTES));primitiveSizesMap.put(long.class, Integer.valueOf(Long.BYTES));primitiveSizes = Collections.unmodifiableMap(primitiveSizesMap);}static final int INTEGER_SIZE, LONG_SIZE, STRING_SIZE;/*** For testing only*/static final boolean JVM_IS_HOTSPOT_64BIT;private static final String UNKNOWN = "Unknown";public static final String OS_ARCH = System.getProperty("os.arch", UNKNOWN);public static final boolean JRE_IS_64BIT = is64Bit();private static boolean is64Bit() {final String datamodel = System.getProperty("sun.arch.data.model");if (datamodel != null) {return datamodel.contains("64");} else {return (OS_ARCH != null && OS_ARCH.contains("64"));}}/** Initialize constants and try to collect information about the JVM internals. */static {if (JRE_IS_64BIT) {JVM_IS_HOTSPOT_64BIT = HotspotVMOptions.IS_HOTSPOT_VM;// Try to get compressed oops and object alignment (the default seems to be 8 on Hotspot);// (this only works on 64 bit, on 32 bits the alignment and reference size is fixed):COMPRESSED_REFS_ENABLED =HotspotVMOptions.get("UseCompressedOops").map(Boolean::valueOf).orElse(false);NUM_BYTES_OBJECT_ALIGNMENT =HotspotVMOptions.get("ObjectAlignmentInBytes").map(Integer::valueOf).orElse(8);// reference size is 4, if we have compressed oops:NUM_BYTES_OBJECT_REF = COMPRESSED_REFS_ENABLED ? 4 : 8;// "best guess" based on reference size:NUM_BYTES_OBJECT_HEADER = 8 + NUM_BYTES_OBJECT_REF;// array header is NUM_BYTES_OBJECT_HEADER + NUM_BYTES_INT, but aligned (object alignment):NUM_BYTES_ARRAY_HEADER = (int) alignObjectSize(NUM_BYTES_OBJECT_HEADER + Integer.BYTES);} else {JVM_IS_HOTSPOT_64BIT = false;COMPRESSED_REFS_ENABLED = false;NUM_BYTES_OBJECT_ALIGNMENT = 8;NUM_BYTES_OBJECT_REF = 4;NUM_BYTES_OBJECT_HEADER = 8;// For 32 bit JVMs, no extra alignment of array header:NUM_BYTES_ARRAY_HEADER = NUM_BYTES_OBJECT_HEADER + Integer.BYTES;}INTEGER_SIZE = (int) shallowSizeOfInstance(Integer.class);LONG_SIZE = (int) shallowSizeOfInstance(Long.class);STRING_SIZE = (int) shallowSizeOfInstance(String.class);}/*** Approximate memory usage that we assign to a Hashtable / HashMap entry.*/public static final long HASHTABLE_RAM_BYTES_PER_ENTRY =// key + value *// hash tables need to be oversized to avoid collisions, assume 2x capacity(2L * NUM_BYTES_OBJECT_REF) * 2;/*** Approximate memory usage that we assign to a LinkedHashMap entry.*/public static final long LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY =HASHTABLE_RAM_BYTES_PER_ENTRY + 2L * NUM_BYTES_OBJECT_REF; // previous & next references/*** Aligns an object size to be the next multiple of {@link #NUM_BYTES_OBJECT_ALIGNMENT}.*/public static long alignObjectSize(long size) {size += (long) NUM_BYTES_OBJECT_ALIGNMENT - 1L;return size - (size % NUM_BYTES_OBJECT_ALIGNMENT);}/*** Return the shallow size of the provided {@link Integer} object. Ignores the possibility that* this object is part of the VM IntegerCache*/public static long sizeOf(Integer ignored) {return INTEGER_SIZE;}/*** Return the shallow size of the provided {@link Long} object. Ignores the possibility that this* object is part of the VM LongCache*/public static long sizeOf(Long ignored) {return LONG_SIZE;}/*** Returns the size in bytes of the byte[] object.*/public static long sizeOf(byte[] arr) {return alignObjectSize((long) NUM_BYTES_ARRAY_HEADER + arr.length);}/*** Returns the size in bytes of the boolean[] object.*/public static long sizeOf(boolean[] arr) {return alignObjectSize((long) NUM_BYTES_ARRAY_HEADER + arr.length);}/*** Returns the size in bytes of the char[] object.*/public static long sizeOf(char[] arr) {return alignObjectSize((long) NUM_BYTES_ARRAY_HEADER + (long) Character.BYTES * arr.length);}/*** Returns the size in bytes of the short[] object.*/public static long sizeOf(short[] arr) {return alignObjectSize((long) NUM_BYTES_ARRAY_HEADER + (long) Short.BYTES * arr.length);}/*** Returns the size in bytes of the int[] object.*/public static long sizeOf(int[] arr) {return alignObjectSize((long) NUM_BYTES_ARRAY_HEADER + (long) Integer.BYTES * arr.length);}/*** Returns the size in bytes of the float[] object.*/public static long sizeOf(float[] arr) {return alignObjectSize((long) NUM_BYTES_ARRAY_HEADER + (long) Float.BYTES * arr.length);}/*** Returns the size in bytes of the long[] object.*/public static long sizeOf(long[] arr) {return alignObjectSize((long) NUM_BYTES_ARRAY_HEADER + (long) Long.BYTES * arr.length);}/*** Returns the size in bytes of the double[] object.*/public static long sizeOf(double[] arr) {return alignObjectSize((long) NUM_BYTES_ARRAY_HEADER + (long) Double.BYTES * arr.length);}/*** Returns the size in bytes of the String[] object.*/public static long sizeOf(String[] arr) {long size = shallowSizeOf(arr);for (String s : arr) {if (s == null) {continue;}size += sizeOf(s);}return size;}/*** Recurse only into immediate descendants.*/public static final int MAX_DEPTH = 1;/*** Returns the size in bytes of a Map object, including sizes of its keys and values, supplying* {@link #UNKNOWN_DEFAULT_RAM_BYTES_USED} when object type is not well known. This method* recurses up to {@link #MAX_DEPTH}.*/public static long sizeOfMap(Map<?, ?> map) {return sizeOfMap(map, 0, UNKNOWN_DEFAULT_RAM_BYTES_USED);}/*** Returns the size in bytes of a Map object, including sizes of its keys and values, supplying* default object size when object type is not well known. This method recurses up to {@link* #MAX_DEPTH}.*/public static long sizeOfMap(Map<?, ?> map, long defSize) {return sizeOfMap(map, 0, defSize);}private static long sizeOfMap(Map<?, ?> map, int depth, long defSize) {if (map == null) {return 0;}long size = shallowSizeOf(map);if (depth > MAX_DEPTH) {return size;}long sizeOfEntry = -1;for (Map.Entry<?, ?> entry : map.entrySet()) {if (sizeOfEntry == -1) {sizeOfEntry = shallowSizeOf(entry);}size += sizeOfEntry;size += sizeOfObject(entry.getKey(), depth, defSize);size += sizeOfObject(entry.getValue(), depth, defSize);}return alignObjectSize(size);}/*** Returns the size in bytes of a Collection object, including sizes of its values, supplying* {@link #UNKNOWN_DEFAULT_RAM_BYTES_USED} when object type is not well known. This method* recurses up to {@link #MAX_DEPTH}.*/public static long sizeOfCollection(Collection<?> collection) {return sizeOfCollection(collection, 0, UNKNOWN_DEFAULT_RAM_BYTES_USED);}/*** Returns the size in bytes of a Collection object, including sizes of its values, supplying* default object size when object type is not well known. This method recurses up to {@link* #MAX_DEPTH}.*/public static long sizeOfCollection(Collection<?> collection, long defSize) {return sizeOfCollection(collection, 0, defSize);}private static long sizeOfCollection(Collection<?> collection, int depth, long defSize) {if (collection == null) {return 0;}long size = shallowSizeOf(collection);if (depth > MAX_DEPTH) {return size;}// assume array-backed collection and add per-object referencessize += NUM_BYTES_ARRAY_HEADER + collection.size() * NUM_BYTES_OBJECT_REF;for (Object o : collection) {size += sizeOfObject(o, depth, defSize);}return alignObjectSize(size);}/*** Best effort attempt to estimate the size in bytes of an undetermined object. Known types will* be estimated according to their formulas, and all other object sizes will be estimated as* {@link #UNKNOWN_DEFAULT_RAM_BYTES_USED}.*/public static long sizeOfObject(Object o) {return sizeOfObject(o, 0, UNKNOWN_DEFAULT_RAM_BYTES_USED);}/*** Best effort attempt to estimate the size in bytes of an undetermined object. Known types will* be estimated according to their formulas, and all other object sizes will be estimated using* {@link #shallowSizeOf(Object)}, or using the supplied <code>defSize</code> parameter if its* value is greater than 0.*/public static long sizeOfObject(Object o, long defSize) {return sizeOfObject(o, 0, defSize);}private static long sizeOfObject(Object o, int depth, long defSize) {if (o == null) {return 0;}long size;if (o instanceof String) {size = sizeOf((String) o);} else if (o instanceof boolean[]) {size = sizeOf((boolean[]) o);} else if (o instanceof byte[]) {size = sizeOf((byte[]) o);} else if (o instanceof char[]) {size = sizeOf((char[]) o);} else if (o instanceof double[]) {size = sizeOf((double[]) o);} else if (o instanceof float[]) {size = sizeOf((float[]) o);} else if (o instanceof int[]) {size = sizeOf((int[]) o);} else if (o instanceof Integer) {size = sizeOf((Integer) o);} else if (o instanceof Long) {size = sizeOf((Long) o);} else if (o instanceof long[]) {size = sizeOf((long[]) o);} else if (o instanceof short[]) {size = sizeOf((short[]) o);} else if (o instanceof String[]) {size = sizeOf((String[]) o);} else if (o instanceof Map) {size = sizeOfMap((Map<?, ?>) o, ++depth, defSize);} else if (o instanceof Collection) {size = sizeOfCollection((Collection<?>) o, ++depth, defSize);} else {if (defSize > 0) {size = defSize;} else {size = shallowSizeOf(o);}}return size;}/*** Returns the size in bytes of the String object.*/public static long sizeOf(String s) {if (s == null) {return 0;}// may not be true in Java 9+ and CompactStrings - but we have no way to determine this// char[] + hashCodelong size = STRING_SIZE + (long) NUM_BYTES_ARRAY_HEADER + (long) Character.BYTES * s.length();return alignObjectSize(size);}/*** Returns the size in bytes of the byte[] object.*/public static long shallowSizeOf(byte[] arr) {return sizeOf(arr);}/*** Returns the size in bytes of the boolean[] object.*/public static long shallowSizeOf(boolean[] arr) {return sizeOf(arr);}/*** Returns the size in bytes of the char[] object.*/public static long shallowSizeOf(char[] arr) {return sizeOf(arr);}/*** Returns the size in bytes of the short[] object.*/public static long shallowSizeOf(short[] arr) {return sizeOf(arr);}/*** Returns the size in bytes of the int[] object.*/public static long shallowSizeOf(int[] arr) {return sizeOf(arr);}/*** Returns the size in bytes of the float[] object.*/public static long shallowSizeOf(float[] arr) {return sizeOf(arr);}/*** Returns the size in bytes of the long[] object.*/public static long shallowSizeOf(long[] arr) {return sizeOf(arr);}/*** Returns the size in bytes of the double[] object.*/public static long shallowSizeOf(double[] arr) {return sizeOf(arr);}/*** Returns the shallow size in bytes of the Object[] object.*/// Use this method instead of #shallowSizeOf(Object) to avoid costly reflectionpublic static long shallowSizeOf(Object[] arr) {return alignObjectSize((long) NUM_BYTES_ARRAY_HEADER + (long) NUM_BYTES_OBJECT_REF * arr.length);}/*** Estimates a "shallow" memory usage of the given object. For arrays, this will be the memory* taken by array storage (no subreferences will be followed). For objects, this will be the* memory taken by the fields.** <p>JVM object alignments are also applied.*/public static long shallowSizeOf(Object obj) {if (obj == null) return 0;final Class<?> clz = obj.getClass();if (clz.isArray()) {return shallowSizeOfArray(obj);} else {return shallowSizeOfInstance(clz);}}/*** Returns the shallow instance size in bytes an instance of the given class would occupy. This* works with all conventional classes and primitive types, but not with arrays (the size then* depends on the number of elements and varies from object to object).** @throws IllegalArgumentException if {@code clazz} is an array class.* @see #shallowSizeOf(Object)*/public static long shallowSizeOfInstance(Class<?> clazz) {if (clazz.isArray())throw new IllegalArgumentException("This method does not work with array classes.");if (clazz.isPrimitive()) return primitiveSizes.get(clazz);long size = NUM_BYTES_OBJECT_HEADER;// Walk type hierarchyfor (; clazz != null; clazz = clazz.getSuperclass()) {final Field[] fields = clazz.getDeclaredFields();for (Field f : fields) {if (!Modifier.isStatic(f.getModifiers())) {size = adjustForField(size, f);}}}return alignObjectSize(size);}/*** Return shallow size of any <code>array</code>.*/private static long shallowSizeOfArray(Object array) {long size = NUM_BYTES_ARRAY_HEADER;final int len = Array.getLength(array);if (len > 0) {Class<?> arrayElementClazz = array.getClass().getComponentType();if (arrayElementClazz.isPrimitive()) {size += (long) len * primitiveSizes.get(arrayElementClazz);} else {size += (long) NUM_BYTES_OBJECT_REF * len;}}return alignObjectSize(size);}/*** This method returns the maximum representation size of an object. <code>sizeSoFar</code> is the* object's size measured so far. <code>f</code> is the field being probed.** <p>The returned offset will be the maximum of whatever was measured so far and <code>f</code>* field's offset and representation size (unaligned).*/public static long adjustForField(long sizeSoFar, final Field f) {final Class<?> type = f.getType();final int fsize = type.isPrimitive() ? primitiveSizes.get(type) : NUM_BYTES_OBJECT_REF;// TODO: No alignments based on field type/ subclass fields alignments?return sizeSoFar + fsize;}/*** Returns <code>size</code> in human-readable units (GB, MB, KB or bytes).*/public static String humanReadableUnits(long bytes) {return humanReadableUnits(bytes, new DecimalFormat("0.#", DecimalFormatSymbols.getInstance(Locale.ROOT)));}/*** Returns <code>size</code> in human-readable units (GB, MB, KB or bytes).*/public static String humanReadableUnits(long bytes, DecimalFormat df) {if (bytes / ONE_GB > 0) {return df.format((float) bytes / ONE_GB) + " GB";} else if (bytes / ONE_MB > 0) {return df.format((float) bytes / ONE_MB) + " MB";} else if (bytes / ONE_KB > 0) {return df.format((float) bytes / ONE_KB) + " KB";} else {return bytes + " bytes";}}/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements.  See the NOTICE file distributed with* this work for additional information regarding copyright ownership.* The ASF licenses this file to You under the Apache License, Version 2.0* (the "License"); you may not use this file except in compliance with* the License.  You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*//*** Accessor to get Hotspot VM Options (if available).*/static final class HotspotVMOptions {private HotspotVMOptions() {} // can't construct/*** True iff the Java VM is based on Hotspot and has the Hotspot MX bean readable by Lucene*/public static final boolean IS_HOTSPOT_VM;/*** Returns an optional with the value of a Hotspot VM option. If the VM option does not exist or* is not readable, returns an empty optional.*/public static Optional<String> get(String name) {return ACCESSOR.apply(Objects.requireNonNull(name, "name"));}private static final String MANAGEMENT_FACTORY_CLASS = "java.lang.management.ManagementFactory";private static final String HOTSPOT_BEAN_CLASS = "com.sun.management.HotSpotDiagnosticMXBean";private static final Function<String, Optional<String>> ACCESSOR;static {boolean isHotspot = false;Function<String, Optional<String>> accessor = name -> Optional.empty();try {final Class<?> beanClazz = Class.forName(HOTSPOT_BEAN_CLASS);// we use reflection for this, because the management factory is not part// of java.base module:final Object hotSpotBean =Class.forName(MANAGEMENT_FACTORY_CLASS).getMethod("getPlatformMXBean", Class.class).invoke(null, beanClazz);if (hotSpotBean != null) {final Method getVMOptionMethod = beanClazz.getMethod("getVMOption", String.class);final Method getValueMethod = getVMOptionMethod.getReturnType().getMethod("getValue");isHotspot = true;accessor =name -> {try {final Object vmOption = getVMOptionMethod.invoke(hotSpotBean, name);return Optional.of(getValueMethod.invoke(vmOption).toString());} catch (@SuppressWarnings("unused")ReflectiveOperationException| RuntimeException e) {return Optional.empty();}};}} catch (@SuppressWarnings("unused") ReflectiveOperationException | RuntimeException e) {final Logger log = Logger.getLogger(HotspotVMOptions.class.getName());final Module module = HotspotVMOptions.class.getModule();final ModuleLayer layer = module.getLayer();// classpath / unnamed module has no layer, so we need to check:if (layer != null&& !layer.findModule("jdk.management").map(module::canRead).orElse(false)) {log.warning("Lucene cannot access JVM internals to optimize algorithms or calculate object sizes, unless the 'jdk.management' Java module "+ "is readable [please add 'jdk.management' to modular application either by command line or its module descriptor].");} else {log.warning("Lucene cannot optimize algorithms or calculate object sizes for JVMs that are not based on Hotspot or a compatible implementation.");}}IS_HOTSPOT_VM = isHotspot;ACCESSOR = accessor;}}}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/374495.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

3102. 最小化曼哈顿距离——leetcode

给你一个下标从 0 开始的数组 points &#xff0c;它表示二维平面上一些点的整数坐标&#xff0c;其中 points[i] [xi, yi] 。 两点之间的距离定义为它们的曼哈顿距离。 请你恰好移除一个点&#xff0c;返回移除后任意两点之间的 最大 距离可能的 最小 值。 示例&#xff1…

【k8s中安装rabbitmq】k8s中基于安装rabbitmq并搭建镜像集群-pvc版

文章目录 简介一.条件及环境说明4.2.创建configmap配置4.3.创建statefulset和service headless配置4.4.授权配置4.5.创建service配置 五.安装完后的配置六.安装说明 简介 该文搭建的rabbitmq集群是采用rabbitmq_peer_discovery_k8s的形式进行搭建&#xff0c;是通过该插件自动从…

这8个AI工具高效无敌,设计师又轻松了!

人工智能工具在设计领域的广泛应用给艺术界带来了巨大的变化。设计师可以使用各种工具来展示他们的创造力和灵感&#xff0c;而不受时间和空间的限制。这些专业的人工智能绘图工具允许设计师看到每一步的最终结果&#xff0c;从而更高效、更方便地创造和设计灵感。因此&#xf…

什么是业务架构、数据架构、应用架构和技术架构

TOGAF(The Open Group Architecture Framework)是一个广泛应用的企业架构框架&#xff0c;旨在帮助组织高效地进行架构设计和管理。而TOGAF的核心就是由我们熟知的四大架构领域组成&#xff1a;业务架构、数据架构、应用架构和技术架构。 所以今天我们就来聊聊&#xff0c;企业…

水文:CBA业务架构师

首先&#xff0c; 我们来了解一下什么是CBA业务架构师&#xff1f; CBA业务架构师认证是由业务架构师公会(Business Architecture Guild)授予的一种专业认证。标志着证书持有者已经掌握了业务架构的核心技能和知识&#xff0c;能够在实际工作中熟练运用业务架构技术和框架&…

SAP S4 销售组的定义和分配

spro-企业结构-定义-销售与分销-维护销售组 新增一个记录 spro-企业结构-分配-销售与分销-给销售办公室分配销售组

c++多态——virtual关键字,C++11 override 和 final,析构函数的重写。

目录 多态基本概念 virtual关键字 C11 override 和 final 举个栗子 析构函数的重写(基类与派生类析构函数的名字不同) 多态基本概念 概念&#xff1a;通俗来说&#xff0c;就是多种形态&#xff0c;具体点就是去完成某个行为&#xff0c;当不同的对象去完成时会 产生出不同…

关于string的‘\0‘与string,vector构造特点,反迭代器与迭代器类等的讨论

目录 问题一&#xff1a;关于string的\0问题讨论 问题二&#xff1a;C标准库中的string内存是分配在堆上面吗&#xff1f; 问题三&#xff1a;string与vector的capacity大小设计的特点 问题四&#xff1a;string的流提取问题 问题五&#xff1a;迭代器失效 问题六&#xf…

filex用户手册中文版解读

filex用户手册 filex的用户手册&#xff0c;看着好头疼呢&#xff0c;主要是没有&#x1f58a;记录&#xff0c;感觉就是浮在空中&#xff0c;飘在天上&#xff0c;好像懂了&#xff0c;又好像啥也没了解到&#xff0c;哈哈&#xff0c;有点意思。为了解决这个bug&#xff0c;…

哪个牌子开放式耳机质量好?五款全网爆火款式盘点!

开放式耳机是目前最流行的一种无线蓝牙耳机&#xff0c;与TWS耳机一样&#xff0c;拥有小巧轻盈的耳机主体&#xff0c;也有便携的补能收纳充电仓&#xff0c;但不同的是&#xff0c;开放式耳机有更加舒适的佩戴体验。作为资深数码产品测评师&#xff0c;我最近测评了多款产品&…

基于前馈神经网络 FNN 实现股票单变量时间序列预测(PyTorch版)

前言 系列专栏:【深度学习&#xff1a;算法项目实战】✨︎ 涉及医疗健康、财经金融、商业零售、食品饮料、运动健身、交通运输、环境科学、社交媒体以及文本和图像处理等诸多领域&#xff0c;讨论了各种复杂的深度神经网络思想&#xff0c;如卷积神经网络、循环神经网络、生成对…

原生小程序生成二维码并保存到本地

需求&#xff1a;我要在一个页面中生成一个二维码&#xff0c;并且这个二维码可以长按保存到本地或者发送给好友&#xff1b; 我这里是将生成的canvas二维码转换成图片&#xff0c;利用长按图片进行保存或转发 效果图&#xff1a; 第一步先下载对应的包&#xff1a; npm instal…

Docker部署gitlab私有仓库后查看root默认密码以及修改external_url路径和端口的方法

文章目录 1、docker部署最新版gitlab2、进入gitlab容器3、修改路径地址ip和端口4、检验效果 1、docker部署最新版gitlab #docker安装命令 docker run --detach \--name gitlab \--restart always \-p 1080:80 \-p 10443:443 \-p 1022:22 \-v /gitlab/config:/etc/gitlab \-v …

Apache中使用CGI

Apache24 使用Visual Studio 2022 // CGI2.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <stdio.h> #include <stdlib.h>#include <stdio.h>void main() {//设置HTML语言printf("Content-type:text/html\n\n&q…

Redis基本命令源码解析-字符串命令

1. set 用于将kv设置到数据库中 2. mset 批量设置kv mset (msetnx) key1 value1 key2 value2 ... mset:msetCommand msetnx:msetnxCommand msetCommand和msetnxCommand都调用msetGenericCommand 2.1 msetGenericCommand 如果参数个数为偶数,则响应参数错误并返回 如果…

【游戏客户端】大话slg玩法架构(二)背景地图

【游戏客户端】大话slg玩法架构&#xff08;二&#xff09;背景地图 大家好&#xff0c;我是Lampard家杰~~ 今天我们继续给大家分享SLG玩法的实现架构&#xff0c;关于SLG玩法的介绍可以参考这篇上一篇文章&#xff1a;【游戏客户端】制作率土之滨Like玩法 PS&#xff1a;和之前…

hudi数据湖万字全方位教程+应用示例

1、时间轴&#xff08;TimeLine&#xff09; Hudi的核心是维护表上在不同的即时时间&#xff08;instants&#xff09;执行的所有操作的时间轴&#xff08;timeline&#xff09;&#xff0c;这有助于提供表的即时视图 一个instant由以下三个部分组成&#xff1a; 1&#xff09;…

视频号矩阵系统源码,实现AI自动生成文案和自动回复私信评论,支持多个短视频平台

在当今短视频蓬勃发展的时代&#xff0c;视频号矩阵系统源码成为了自媒体人争相探索的宝藏。这一强大的技术工具不仅能帮助我们高效管理多个短视频平台&#xff0c;更能通过AI智能生成文案和自动回复私信评论&#xff0c;为自媒体运营带来前所未有的便利与效率。 一、视频号矩…

layui-表单(输入框)

1.基本使用方法 先写一个表单元素块 form 加上layui-form 里面写行区块结构&#xff0c;如下&#xff1a; 2.输入框样式选项 input框 placeholder默认文本 autocomplete自动填充 lay-verify required必填 3.下拉菜单样式选项 默认选择第一项 select框 disable禁…

导员:你这么牛,那你来讲讲你项目的核心流程-判题模块吧

耗时一个月开发的OJ在线判题系统&#xff0c;文末有项目地址&#xff0c;目前还在更新代码~ 今天我们来开发OJ系统后端核心流程之一的判题模块 文章目录 判题机模块与代码沙箱的关系代码沙箱架构开发判题服务开发判题服务业务流程判断逻辑策略模式优化 小知识-Lombox Builder …